diff options
author | David Blaikie <dblaikie@gmail.com> | 2012-05-30 20:45:14 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2012-05-30 20:45:14 +0000 |
commit | abe21e36d789cfe800562a1e889738addfd2ac5b (patch) | |
tree | a5fbff16c03bcbac0661cb9f3d336a897f813b8e /lib/Sema/SemaDecl.cpp | |
parent | b4a542549c2e0c9eeb6ece3f95767ccdd141fa3e (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157713 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 8f991c7fe1..d194d9f100 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -10245,6 +10245,9 @@ static void CheckForUniqueEnumValues(Sema &S, Decl **Elements, if (NumElements < 2) return; + if (!Enum->getIdentifier()) + return; + llvm::APSInt FirstVal; for (unsigned i = 0; i != NumElements; ++i) { @@ -10268,9 +10271,8 @@ static void CheckForUniqueEnumValues(Sema &S, Decl **Elements, 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(); } |