diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-02-20 01:18:21 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-02-20 01:18:21 +0000 |
commit | 719ed1a9ab552235d104c72feabc3029f4045755 (patch) | |
tree | 84aa4e98e7fced6cf980e6f56df1a111f2face8f /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 742421e2e7887ef018585e5fdbbad647a9dfca5b (diff) | |
download | bcm5719-llvm-719ed1a9ab552235d104c72feabc3029f4045755.tar.gz bcm5719-llvm-719ed1a9ab552235d104c72feabc3029f4045755.zip |
Initialize the Init variable to something reasonable when we emit an
error, so we don't crash.
llvm-svn: 65099
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 3d01770cd3a..7432b01e255 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -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(); |