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 | 04ca19b97e85381920df7214f2c31b6833b314ce (patch) | |
tree | ac02a8ae140ee3e99ab93b6e30228040bc58d7a3 /lib/Sema/SemaDecl.cpp | |
parent | 6734ec41ab596088fd157b127f98aeae59ce8e6d (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159458 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 40643896fd..40ec1baddb 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/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, |