aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2013-04-07 14:10:40 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2013-04-07 14:10:40 +0000
commitefac8da4cfa49799d5fdbc9d10b0e9f9a53ff6c8 (patch)
tree6fa78e2978a9359229e5125995b56f889b8696a9 /lib/Sema/SemaDecl.cpp
parent6797204b89c0edb9496249fba557b45d8cc9ec76 (diff)
Sema: Don't crash when trying to emit a warning for a duplicate value in an invalid enum.
Fixes PR15693. A null check on a pointer returned from cast<> is a very dubious construct, do we have a checker for this somewhere? git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178975 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp2
1 files changed, 1 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.