]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/41611 (guard variable is emitted even when the guarded symbol isn't)
authorJason Merrill <jason@redhat.com>
Fri, 4 Dec 2009 00:26:35 +0000 (19:26 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 4 Dec 2009 00:26:35 +0000 (19:26 -0500)
PR c++/41611
* decl2.c (get_guard): Don't use the same comdat group as the decl.

From-SVN: r154965

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

index deb59030bd00a88b7db8fdb1d6e21aad523b33f4..cdbd1c48a1f460ee10ddcc85c46f6f8d7ae1af9d 100644 (file)
@@ -1,5 +1,8 @@
 2009-12-03  Jason Merrill  <jason@redhat.com>
 
+       PR c++/41611
+       * decl2.c (get_guard): Don't use the same comdat group as the decl.
+
        PR c++/42266
        * cvt.c (convert_from_reference): Do nothing if TREE_TYPE is null.
 
index 1cd2ded03a3fe38c85cc0ed06ae4432125e3ec15..faa3c9d45a96bbfd6880523d777f0d3bf4d1a467 100644 (file)
@@ -2555,7 +2555,8 @@ get_guard (tree 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 (DECL_ONE_ONLY (decl))
+       make_decl_one_only (guard, cxx_comdat_group (guard));
       if (TREE_PUBLIC (decl))
        DECL_WEAK (guard) = DECL_WEAK (decl);
       DECL_VISIBILITY (guard) = DECL_VISIBILITY (decl);
index ff7a355f451badcefe001582366d99625f36f452..c68c0b64d4e9732ccd848b0fb9bd76307e27bee6 100644 (file)
@@ -1,5 +1,8 @@
 2009-12-03  Jason Merrill  <jason@redhat.com>
 
+       PR c++/41611
+       * g++.dg/abi/guard2.C: New.
+
        PR c++/42266
        * g++.dg/cpp0x/variadic97.C: New.
 
diff --git a/gcc/testsuite/g++.dg/abi/guard2.C b/gcc/testsuite/g++.dg/abi/guard2.C
new file mode 100644 (file)
index 0000000..09643e9
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/41611
+// Test that the guard gets its own COMDAT group.
+// { dg-final { scan-assembler "_ZGVZN1A1fEvE1i,comdat" { target i?86-*-* x86_64-*-* } } }
+
+struct A {
+  static int f()
+  {
+    static int &i = *new int();
+    return i;
+  }
+};
+
+int main()
+{
+  return A::f();
+}