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  <pola...@redhat.com>

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

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

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;
+      }
+    };
+  }
+};

        Marek

Reply via email to