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
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user