aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td4
-rw-r--r--lib/Sema/SemaDecl.cpp6
-rw-r--r--test/SemaCXX/warn-unique-enum.cpp2
3 files changed, 7 insertions, 5 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index b62e3aefae..206cbe1056 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -21,8 +21,8 @@ def warn_variables_not_in_loop_body : Warning<
InGroup<DiagGroup<"loop-analysis">>, DefaultIgnore;
def warn_identical_enum_values : Warning<
- "all elements of %select{anonymous enum|%1}0 are initialized with literals "
- "to value %2">, InGroup<DiagGroup<"unique-enum">>;
+ "all elements of %0 are initialized with literals to value %1">,
+ InGroup<DiagGroup<"unique-enum">>;
// Constant expressions
def err_expr_not_ice : Error<
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();
}
diff --git a/test/SemaCXX/warn-unique-enum.cpp b/test/SemaCXX/warn-unique-enum.cpp
index ddafc16aab..7d04b1dc2d 100644
--- a/test/SemaCXX/warn-unique-enum.cpp
+++ b/test/SemaCXX/warn-unique-enum.cpp
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 %s -fsyntax-only -verify -Wunique-enum
enum A { A1 = 1, A2 = 1, A3 = 1 }; // expected-warning {{all elements of 'A' are initialized with literals to value 1}}
-enum { B1 = 1, B2 = 1, B3 = 1 }; // expected-warning {{all elements of anonymous enum are initialized with literals to value 1}}
+enum { B1 = 1, B2 = 1, B3 = 1 }; // no warning
enum C { C1 = true, C2 = true}; // expected-warning {{all elements of 'C' are initialized with literals to value 1}}
enum D { D1 = 5, D2 = 5L, D3 = 5UL, D4 = 5LL, D5 = 5ULL }; // expected-warning {{all elements of 'D' are initialized with literals to value 5}}