forked from OSchip/llvm-project
Make sure to always mark a global variable as not being constant if it has a C++ initializer.
llvm-svn: 94504
This commit is contained in:
parent
19afd61201
commit
20bbbd489b
|
@ -138,8 +138,13 @@ CodeGenFunction::AddInitializerToGlobalBlockVarDecl(const VarDecl &D,
|
|||
if (!Init) {
|
||||
if (!getContext().getLangOptions().CPlusPlus)
|
||||
CGM.ErrorUnsupported(D.getInit(), "constant l-value expression");
|
||||
else
|
||||
else {
|
||||
// Since we have a static initializer, this global variable can't
|
||||
// be constant.
|
||||
GV->setConstant(false);
|
||||
|
||||
EmitStaticCXXBlockVarDeclInit(D, GV);
|
||||
}
|
||||
return GV;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
|
||||
|
||||
// CHECK: @_ZZ1hvE1i = internal global i32 0, align 4
|
||||
struct A {
|
||||
A();
|
||||
~A();
|
||||
|
@ -15,3 +17,8 @@ void g() {
|
|||
// CHECK: call void @_ZN1AC1Ev(
|
||||
static A& a = *new A;
|
||||
}
|
||||
|
||||
int a();
|
||||
void h() {
|
||||
static const int i = a();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue