mirror of
https://github.com/intel/llvm.git
synced 2026-01-16 21:55:39 +08:00
Static local variables don't result in global constructors being emitted.
llvm-svn: 112933
This commit is contained in:
@@ -2039,7 +2039,6 @@
|
||||
isa = PBXProject;
|
||||
buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
|
||||
compatibilityVersion = "Xcode 2.4";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 1;
|
||||
knownRegions = (
|
||||
English,
|
||||
|
||||
@@ -4280,7 +4280,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
|
||||
if (getLangOptions().CPlusPlus) {
|
||||
if (!VDecl->isInvalidDecl() &&
|
||||
!VDecl->getDeclContext()->isDependentContext() &&
|
||||
VDecl->hasGlobalStorage() &&
|
||||
VDecl->hasGlobalStorage() && !VDecl->isStaticLocal() &&
|
||||
!Init->isConstantInitializer(Context,
|
||||
VDecl->getType()->isReferenceType()))
|
||||
Diag(VDecl->getLocation(), diag::warn_global_constructor)
|
||||
@@ -4492,7 +4492,7 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl,
|
||||
Var->setInit(MaybeCreateCXXExprWithTemporaries(Init.takeAs<Expr>()));
|
||||
|
||||
if (getLangOptions().CPlusPlus && !Var->isInvalidDecl() &&
|
||||
Var->hasGlobalStorage() &&
|
||||
Var->hasGlobalStorage() && !Var->isStaticLocal() &&
|
||||
!Var->getDeclContext()->isDependentContext() &&
|
||||
!Var->getInit()->isConstantInitializer(Context, false))
|
||||
Diag(Var->getLocation(), diag::warn_global_constructor);
|
||||
|
||||
@@ -56,3 +56,26 @@ namespace test4 {
|
||||
char b[5] = "hello";
|
||||
char c[][5] = { "hello" };
|
||||
}
|
||||
|
||||
namespace test5 {
|
||||
struct A { A(); };
|
||||
|
||||
void f1() {
|
||||
static A a;
|
||||
}
|
||||
void f2() {
|
||||
static A& a = *new A;
|
||||
}
|
||||
}
|
||||
|
||||
namespace test6 {
|
||||
struct A { ~A(); };
|
||||
|
||||
void f1() {
|
||||
static A a; // expected-warning {{global destructor}}
|
||||
}
|
||||
void f2() {
|
||||
static A& a = *new A;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user