]> granicus.if.org Git - clang/commitdiff
Don't give 'global constructor' warnings for function statics, even if they have...
authorSebastian Redl <sebastian.redl@getdesigned.at>
Wed, 8 Sep 2010 04:46:19 +0000 (04:46 +0000)
committerSebastian Redl <sebastian.redl@getdesigned.at>
Wed, 8 Sep 2010 04:46:19 +0000 (04:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113344 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/warn-global-constructors.cpp

index 63acdb5f1cc6e0e9a86b055da563611b1a46dd19..7205abdbc21b7432b8ec49bb6ba5f4f7f49cc135 100644 (file)
@@ -5622,7 +5622,7 @@ void Sema::AddCXXDirectInitializerToDecl(Decl *RealDecl,
 
     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)
index 107bbe129f67b9f6cfa290e8c7cd2d5901e730fb..e14117eaf3b7a9a4d82d1a38123280bdb01d1530 100644 (file)
@@ -77,5 +77,15 @@ namespace test6 {
   void f2() {
     static A& a = *new A;
   }
+}
+
+namespace pr8095 {
+  struct Foo {
+    int x;
+    Foo(int x1) : x(x1) {}
+  };
 
-}
\ No newline at end of file
+  void bar() {
+    static Foo a(0);
+  }
+}