diff options
author | Richard Trieu <rtrieu@google.com> | 2012-06-29 20:36:14 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2012-06-29 20:36:14 +0000 |
commit | cf86744ffeb267c85fe485c26ecc1c906af1b6a7 (patch) | |
tree | 441126bf27bc2b97ca22875c285925ed7da341bf /clang/lib/Sema | |
parent | 396b3adc10e44fd4be4898e05db0794eaac5dbe5 (diff) | |
download | bcm5719-llvm-cf86744ffeb267c85fe485c26ecc1c906af1b6a7.tar.gz bcm5719-llvm-cf86744ffeb267c85fe485c26ecc1c906af1b6a7.zip |
Add a fix-it hint note to -Wunique-enum to suggest that the last element gets
initialized with the next to last element to silence the warning.
llvm-svn: 159458
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 40643896fd3..40ec1baddba 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -10364,6 +10364,13 @@ static void CheckForUniqueEnumValues(Sema &S, Decl **Elements, S.Diag(Enum->getLocation(), diag::warn_identical_enum_values) << EnumType << FirstVal.toString(10) << Enum->getSourceRange(); + + EnumConstantDecl *Last = cast<EnumConstantDecl>(Elements[NumElements - 1]), + *Next = cast<EnumConstantDecl>(Elements[NumElements - 2]); + + S.Diag(Last->getLocation(), diag::note_identical_enum_values) + << FixItHint::CreateReplacement(Last->getInitExpr()->getSourceRange(), + Next->getName()); } void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc, |