summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-05-05 20:15:55 +0000
committerDouglas Gregor <dgregor@apple.com>2010-05-05 20:15:55 +0000
commitd450f06ef4243e45fb078edeffcccc21915c1247 (patch)
tree0eeac89de49ba7ea79dd4c97264ede65bc0d20aa /clang/lib/CodeGen
parente36cd72e38e1a742c79f730f968bb4f8f16f33eb (diff)
downloadbcm5719-llvm-d450f06ef4243e45fb078edeffcccc21915c1247.tar.gz
bcm5719-llvm-d450f06ef4243e45fb078edeffcccc21915c1247.zip
When we emit a non-constant initializer for a global variable of
reference type, make sure that the initializer we build is the of the appropriate type for the *reference*, not for the thing that it refers to. Fixes PR7050. llvm-svn: 103115
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index cc90a2855de..9c84bcec054 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1101,10 +1101,12 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
assert(!ASTTy->isIncompleteType() && "Unexpected incomplete type");
Init = EmitNullConstant(D->getType());
} else {
- Init = EmitConstantExpr(InitExpr, D->getType());
-
+ Init = EmitConstantExpr(InitExpr, D->getType());
if (!Init) {
QualType T = InitExpr->getType();
+ if (D->getType()->isReferenceType())
+ T = D->getType();
+
if (getLangOptions().CPlusPlus) {
EmitCXXGlobalVarDeclInitFunc(D);
Init = EmitNullConstant(T);
OpenPOWER on IntegriCloud