aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2009-12-03 19:26:35 -0500
committerJason Merrill <jason@gcc.gnu.org>2009-12-03 19:26:35 -0500
commitd35311a213ec3974c2bf91311ebd1380ffd080d4 (patch)
tree3bc1df70e054a261cac8b5c41b0347f58b4a3919
parent4e3f6d8529cfab76897fa4f1618409efdd468ae7 (diff)
downloadgcc-d35311a213ec3974c2bf91311ebd1380ffd080d4.zip
gcc-d35311a213ec3974c2bf91311ebd1380ffd080d4.tar.gz
gcc-d35311a213ec3974c2bf91311ebd1380ffd080d4.tar.bz2
re PR middle-end/41611 (guard variable is emitted even when the guarded symbol isn't)
PR c++/41611 * decl2.c (get_guard): Don't use the same comdat group as the decl. From-SVN: r154965
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/decl2.c3
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/abi/guard2.C16
4 files changed, 24 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index deb5903..cdbd1c4 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 1cd2ded..faa3c9d 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -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);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ff7a355..c68c0b6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..09643e9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/guard2.C
@@ -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();
+}