diff options
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 2 | ||||
-rw-r--r-- | test/Sema/warn-duplicate-enum.c | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 84d992c878..c8a5d932e7 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -11538,7 +11538,7 @@ static void CheckForDuplicateEnumValues(Sema &S, Decl **Elements, // Populate the EnumMap with all values represented by enum constants without // an initialier. for (unsigned i = 0; i < NumElements; ++i) { - EnumConstantDecl *ECD = cast<EnumConstantDecl>(Elements[i]); + EnumConstantDecl *ECD = cast_or_null<EnumConstantDecl>(Elements[i]); // Null EnumConstantDecl means a previous diagnostic has been emitted for // this constant. Skip this enum since it may be ill-formed. diff --git a/test/Sema/warn-duplicate-enum.c b/test/Sema/warn-duplicate-enum.c index 239f6f1995..f108b3aa6c 100644 --- a/test/Sema/warn-duplicate-enum.c +++ b/test/Sema/warn-duplicate-enum.c @@ -90,3 +90,12 @@ enum { NMax = N2, NCount = NMax + 1 }; + +// PR15693 +enum enum1 { + VALUE // expected-note{{previous definition is here}} +}; + +enum enum2 { + VALUE // expected-error{{redefinition of enumerator 'VALUE'}} +}; |