diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 0580392689b6..4816d22013fa 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -5519,7 +5519,8 @@ void Sema::FinalizeVarWithDestructor(VarDecl *VD, const RecordType *Record) { << VD->getDeclName() << VD->getType()); - if (!VD->isInvalidDecl() && VD->hasGlobalStorage()) + // TODO: this should be re-enabled for static locals by !CXAAtExit + if (!VD->isInvalidDecl() && VD->hasGlobalStorage() && !VD->isStaticLocal()) Diag(VD->getLocation(), diag::warn_global_destructor); } } diff --git a/clang/test/SemaCXX/warn-global-constructors.cpp b/clang/test/SemaCXX/warn-global-constructors.cpp index 0391f5ba3d1f..ad609545ece1 100644 --- a/clang/test/SemaCXX/warn-global-constructors.cpp +++ b/clang/test/SemaCXX/warn-global-constructors.cpp @@ -72,7 +72,7 @@ namespace test6 { struct A { ~A(); }; void f1() { - static A a; // expected-warning {{global destructor}} + static A a; } void f2() { static A& a = *new A; @@ -84,8 +84,14 @@ namespace pr8095 { int x; Foo(int x1) : x(x1) {} }; - - void bar() { + void foo() { static Foo a(0); } + + struct Bar { + ~Bar(); + }; + void bar() { + static Bar b; + } }