]> granicus.if.org Git - clang/commitdiff
PR3330: given an enum like this:
authorChris Lattner <sabre@nondot.org>
Thu, 15 Jan 2009 19:19:42 +0000 (19:19 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 15 Jan 2009 19:19:42 +0000 (19:19 +0000)
enum E {
 A = 1U,
 B
};

Don't make an implicit cast expr of null for B.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62274 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp

index 07966399da87827461fd883ac750fde3ac2277a9..e9435521d18b8e592af2f41c75d17712acd7dd67 100644 (file)
@@ -3684,8 +3684,9 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, DeclTy *EnumDeclX,
     ECD->setInitVal(InitVal);
     
     // Adjust the Expr initializer and type.
-    ECD->setInitExpr(new ImplicitCastExpr(NewTy, ECD->getInitExpr(), 
-                                          /*isLvalue=*/false));
+    if (ECD->getInitExpr())
+      ECD->setInitExpr(new ImplicitCastExpr(NewTy, ECD->getInitExpr(), 
+                                            /*isLvalue=*/false));
     if (getLangOptions().CPlusPlus)
       // C++ [dcl.enum]p4: Following the closing brace of an
       // enum-specifier, each enumerator has the type of its