diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-05-05 19:16:15 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-05-05 19:16:15 +0000 |
commit | dce10ead9856949aee45ec9db4fae5d1e5893192 (patch) | |
tree | ffa29c28effef9c75ab15af69cff6baaa6f42c91 /clang/lib/Sema/SemaDeclCXX.cpp | |
parent | 8eb53c8e22cb3d595679fdcc2d7fdb5cd5513181 (diff) | |
download | bcm5719-llvm-dce10ead9856949aee45ec9db4fae5d1e5893192.tar.gz bcm5719-llvm-dce10ead9856949aee45ec9db4fae5d1e5893192.zip |
Add a FixItHint for the new diagnostic for a non-class-scope using-declaration that names a class-scope enumerator.
llvm-svn: 268664
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index f478f0419b2..95f10f8cccf 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -8421,6 +8421,20 @@ bool Sema::CheckUsingDeclQualifier(SourceLocation UsingLoc, Diag(UsingLoc, diag::note_using_decl_class_member_workaround) << 2 // reference declaration << FixIt; + } else if (R.getAsSingle<EnumConstantDecl>()) { + // Don't provide a fixit outside C++11 mode; we don't want to suggest + // repeating the type of the enumeration here, and we can't do so if + // the type is anonymous. + FixItHint FixIt; + if (getLangOpts().CPlusPlus11) { + // Convert 'using X::Y;' to 'auto &Y = X::Y;'. + FixIt = FixItHint::CreateReplacement( + UsingLoc, "constexpr auto " + NameInfo.getName().getAsString() + " = "); + } + + Diag(UsingLoc, diag::note_using_decl_class_member_workaround) + << (getLangOpts().CPlusPlus11 ? 4 : 3) // const[expr] variable + << FixIt; } return true; } |