PR c++/41611
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 1 Dec 2009 21:58:04 +0000 (21:58 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 1 Dec 2009 21:58:04 +0000 (21:58 +0000)
* decl2.c (get_guard): Copy DECL_COMDAT.
(comdat_linkage): Set DECL_COMDAT unconditionally.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154885 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/abi/guard1.C [new file with mode: 0644]

index c185333..f0b9d7f 100644 (file)
@@ -1,3 +1,9 @@
+2009-12-01  Jason Merrill  <jason@redhat.com>
+
+       PR c++/41611
+       * decl2.c (get_guard): Copy DECL_COMDAT.
+       (comdat_linkage): Set DECL_COMDAT unconditionally.
+
 2009-12-01  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/3187
index c0febad..1cd2ded 100644 (file)
@@ -1574,8 +1574,7 @@ comdat_linkage (tree decl)
        }
     }
 
-  if (DECL_LANG_SPECIFIC (decl))
-    DECL_COMDAT (decl) = 1;
+  DECL_COMDAT (decl) = 1;
 }
 
 /* For win32 we also want to put explicit instantiations in
@@ -2555,6 +2554,7 @@ get_guard (tree decl)
       TREE_PUBLIC (guard) = TREE_PUBLIC (decl);
       TREE_STATIC (guard) = TREE_STATIC (decl);
       DECL_COMMON (guard) = DECL_COMMON (decl);
+      DECL_COMDAT (guard) = DECL_COMDAT (decl);
       DECL_COMDAT_GROUP (guard) = DECL_COMDAT_GROUP (decl);
       if (TREE_PUBLIC (decl))
        DECL_WEAK (guard) = DECL_WEAK (decl);
index b73a142..2b856c2 100644 (file)
@@ -1,3 +1,8 @@
+2009-12-01  Jason Merrill  <jason@redhat.com>
+
+       PR c++/41611
+       * g++.dg/abi/guard1.C: New.
+
 2009-12-91  Uros Bizjak  <ubizjak@gmail.com>
 
        * gcc.target/i386/vperm-v4sf-1.c (dg-options): Use -msse.
diff --git a/gcc/testsuite/g++.dg/abi/guard1.C b/gcc/testsuite/g++.dg/abi/guard1.C
new file mode 100644 (file)
index 0000000..76b43d3
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/41611
+// { dg-final { scan-assembler-not "_ZGVZN1A1fEvE1i" } }
+
+struct A {
+  static int f()
+  {
+    static int &i = *new int();
+    return i;
+  }
+};