r204825 - -Wglobal-constructors: Don't warn on trivial defaulted dtors
Reid Kleckner
reid at kleckner.net
Wed Mar 26 08:58:20 PDT 2014
Author: rnk
Date: Wed Mar 26 10:58:20 2014
New Revision: 204825
URL: http://llvm.org/viewvc/llvm-project?rev=204825&view=rev
Log:
-Wglobal-constructors: Don't warn on trivial defaulted dtors
Fixes PR19253.
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/warn-global-constructors.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=204825&r1=204824&r2=204825&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Mar 26 10:58:20 2014
@@ -10470,7 +10470,7 @@ void Sema::FinalizeVarWithDestructor(Var
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);
}
Modified: cfe/trunk/test/SemaCXX/warn-global-constructors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-global-constructors.cpp?rev=204825&r1=204824&r2=204825&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-global-constructors.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-global-constructors.cpp Wed Mar 26 10:58:20 2014
@@ -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}}
+}
More information about the cfe-commits
mailing list