-Wglobal-constructors: Don't warn on trivial defaulted dtors

Fixes PR19253.

llvm-svn: 204825
This commit is contained in:
Reid Kleckner 2014-03-26 15:58:20 +00:00
parent e31dd3473e
commit c511f43b67
2 changed files with 10 additions and 2 deletions

View File

@ -10470,7 +10470,7 @@ void Sema::FinalizeVarWithDestructor(VarDecl *VD, const RecordType *Record) {
Diag(VD->getLocation(), diag::warn_exit_time_destructor);
// TODO: this should be re-enabled for static locals by !CXAAtExit
if (!VD->isStaticLocal())
if (!Destructor->isTrivial() && !VD->isStaticLocal())
Diag(VD->getLocation(), diag::warn_global_destructor);
}

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only -Wglobal-constructors %s -verify
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wglobal-constructors %s -verify
int opaque_int();
@ -101,3 +101,11 @@ namespace referencemember {
int a;
A b = { a };
}
namespace pr19253 {
struct A { ~A() = default; };
A a;
struct B { ~B() {} };
struct C : B { ~C() = default; };
C c; // expected-warning {{global destructor}}
}