Disable -Wunique-enum for anonymous enums.
This is a large class of false positives where anonymous enums are used to
declare constants (see Clang's Diagnostics.h for example). A small number of
true positives could probably be found in this bucket by still warning if the
anonymous enum is used in a declarator (enum { ... } x;) but so far we don't
believe this to be a source of significant benefit so I haven't bothered to
preserve those cases.
General offline review/acknowledgment by rtrieu.
llvm-svn: 157713
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 8f991c7..d194d9f 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -10245,6 +10245,9 @@
if (NumElements < 2)
return;
+ if (!Enum->getIdentifier())
+ return;
+
llvm::APSInt FirstVal;
for (unsigned i = 0; i != NumElements; ++i) {
@@ -10268,9 +10271,8 @@
return;
}
- bool hasIdentifier = Enum->getIdentifier();
S.Diag(Enum->getLocation(), diag::warn_identical_enum_values)
- << hasIdentifier << EnumType << FirstVal.toString(10)
+ << EnumType << FirstVal.toString(10)
<< Enum->getSourceRange();
}