summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2012-06-29 20:36:14 +0000
committerRichard Trieu <rtrieu@google.com>2012-06-29 20:36:14 +0000
commitcf86744ffeb267c85fe485c26ecc1c906af1b6a7 (patch)
tree441126bf27bc2b97ca22875c285925ed7da341bf /clang/lib/Sema
parent396b3adc10e44fd4be4898e05db0794eaac5dbe5 (diff)
downloadbcm5719-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.cpp7
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,
OpenPOWER on IntegriCloud