diff options
author | Anders Carlsson <andersca@mac.com> | 2010-01-26 17:43:42 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-01-26 17:43:42 +0000 |
commit | ca4a5459d8034123868fd3cee7fb190d90c1414b (patch) | |
tree | bf38d3da4461cf958313daa628762115deeb1307 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 7228117108b2c3b622a9607255bbb2be4e8bc6f5 (diff) | |
download | bcm5719-llvm-ca4a5459d8034123868fd3cee7fb190d90c1414b.tar.gz bcm5719-llvm-ca4a5459d8034123868fd3cee7fb190d90c1414b.zip |
Use the right definition when emitting a global variable. Fixes PR5564.
llvm-svn: 94555
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 4eb8bd8d9ff..ebd3df1cf93 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -979,7 +979,9 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) { QualType ASTTy = D->getType(); bool NonConstInit = false; - if (D->getInit() == 0) { + const Expr *InitExpr = D->getDefinition(); + + if (!InitExpr) { // This is a tentative definition; tentative definitions are // implicitly initialized with { 0 }. // @@ -992,10 +994,10 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) { assert(!ASTTy->isIncompleteType() && "Unexpected incomplete type"); Init = EmitNullConstant(D->getType()); } else { - Init = EmitConstantExpr(D->getInit(), D->getType()); + Init = EmitConstantExpr(InitExpr, D->getType()); if (!Init) { - QualType T = D->getInit()->getType(); + QualType T = InitExpr->getType(); if (getLangOptions().CPlusPlus) { EmitCXXGlobalVarDeclInitFunc(D); Init = EmitNullConstant(T); |