[cfe-commits] r113344 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaCXX/warn-global-constructors.cpp
Sebastian Redl
sebastian.redl at getdesigned.at
Tue Sep 7 21:46:20 PDT 2010
Author: cornedbee
Date: Tue Sep 7 23:46:19 2010
New Revision: 113344
URL: http://llvm.org/viewvc/llvm-project?rev=113344&view=rev
Log:
Don't give 'global constructor' warnings for function statics, even if they have a direct initializer. Fixes PR8095.
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=113344&r1=113343&r2=113344&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Sep 7 23:46:19 2010
@@ -5622,7 +5622,7 @@
if (!VDecl->isInvalidDecl() &&
!VDecl->getDeclContext()->isDependentContext() &&
- VDecl->hasGlobalStorage() &&
+ VDecl->hasGlobalStorage() && !VDecl->isStaticLocal() &&
!VDecl->getInit()->isConstantInitializer(Context,
VDecl->getType()->isReferenceType()))
Diag(VDecl->getLocation(), diag::warn_global_constructor)
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=113344&r1=113343&r2=113344&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-global-constructors.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-global-constructors.cpp Tue Sep 7 23:46:19 2010
@@ -77,5 +77,15 @@
void f2() {
static A& a = *new A;
}
+}
-}
\ No newline at end of file
+namespace pr8095 {
+ struct Foo {
+ int x;
+ Foo(int x1) : x(x1) {}
+ };
+
+ void bar() {
+ static Foo a(0);
+ }
+}
More information about the cfe-commits
mailing list