]> granicus.if.org Git - clang/commitdiff
Initialize the Init variable to something reasonable when we emit an
authorEli Friedman <eli.friedman@gmail.com>
Fri, 20 Feb 2009 01:18:21 +0000 (01:18 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Fri, 20 Feb 2009 01:18:21 +0000 (01:18 +0000)
error, so we don't crash.

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

lib/CodeGen/CodeGenModule.cpp

index 3d01770cd3a07bf2b38a2e6a9df607542183d870..7432b01e255cca67d2565ab809b441b4ec34805b 100644 (file)
@@ -626,8 +626,11 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
     Init = llvm::Constant::getNullValue(InitTy);
   } else {
     Init = EmitConstantExpr(D->getInit());
-    if (!Init)
+    if (!Init) {
       ErrorUnsupported(D, "static initializer");
+      QualType T = D->getInit()->getType();
+      Init = llvm::UndefValue::get(getTypes().ConvertType(T));
+    }
   }
   const llvm::Type* InitType = Init->getType();