diff mbox

C++ PATCH for c++/69113 (ICE with -fno-weak)

Message ID 20160108201643.GO31604@redhat.com
State New
Headers show

Commit Message

Marek Polacek Jan. 8, 2016, 8:16 p.m. UTC
Looking at the second Jason's patch here 
<https://gcc.gnu.org/ml/gcc-patches/2015-04/msg00781.html>
it seems that we should never set DECL_COMDAT on a decl that is !TREE_PUBLIC.

The following test was breaking with -fno-weak, because there we set DECL_COMDAT
on something that was !TREE_PUBLIC and the assert in vague_linkage_p was upset
about that.  I'm unsure about all this comdat business but the following fixes
the ICE.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2016-01-08  Marek Polacek  <polacek@redhat.com>

	PR c++/69113
	* decl2.c (comdat_linkage): Only set DECL_COMDAT if TREE_PUBLIC is set.

	* g++.dg/pr69113.C: New test.


	Marek

Comments

Jason Merrill Jan. 9, 2016, 5:13 a.m. UTC | #1
OK.

Jason
diff mbox

Patch

diff --git gcc/cp/decl2.c gcc/cp/decl2.c
index 9a07e1e..a7212ca0 100644
--- gcc/cp/decl2.c
+++ gcc/cp/decl2.c
@@ -1820,7 +1820,8 @@  comdat_linkage (tree decl)
 	}
     }
 
-  DECL_COMDAT (decl) = 1;
+  if (TREE_PUBLIC (decl))
+    DECL_COMDAT (decl) = 1;
 }
 
 /* For win32 we also want to put explicit instantiations in
diff --git gcc/testsuite/g++.dg/pr69113.C gcc/testsuite/g++.dg/pr69113.C
index e69de29..2f8331e 100644
--- gcc/testsuite/g++.dg/pr69113.C
+++ gcc/testsuite/g++.dg/pr69113.C
@@ -0,0 +1,17 @@ 
+// PR c++/69113
+// { dg-do compile }
+// { dg-options "-fno-weak" }
+
+struct foo
+{
+  static void bar ()
+  {
+    struct baz
+    {
+      static void m ()
+      {
+	static int n;
+      }
+    };
+  }
+};