re PR c++/79091 (ICE in write_unnamed_type)
authorNathan Sidwell <nathan@acm.org>
Wed, 18 Jan 2017 12:51:28 +0000 (12:51 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Wed, 18 Jan 2017 12:51:28 +0000 (12:51 +0000)
PR c++/79091
* mangle.c (write_exception_spec): Check nothrow explicitly.
(write_encoding): Don't increment processing_template_decl around
encoding.

PR c++/79091
* g++.dg/pr79091.C: New.

From-SVN: r244575

gcc/cp/ChangeLog
gcc/cp/mangle.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/pr79091.C [new file with mode: 0644]

index a42454a478a12afb21ff3825784d8cf0e2f42a70..7733be7cc523d6d85ecbb482c3f78936480b36a4 100644 (file)
@@ -1,3 +1,10 @@
+2017-01-18  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/79091
+       * mangle.c (write_exception_spec): Check nothrow explicitly.
+       (write_encoding): Don't increment processing_template_decl around
+       encoding.
+
 2017-01-18  Markus Trippelsdorf  <markus@trippelsdorf.de>
 
        PR c++/70182
index d1b107cbb1d46d505ce4f13d44e83ac0fc562dce..033660f00917e938a91c423382bbaad9c5ebd0a1 100644 (file)
@@ -366,17 +366,19 @@ write_exception_spec (tree spec)
       return;
     }
 
-  if (nothrow_spec_p (spec))
+  if (spec == noexcept_true_spec || spec == empty_except_spec)
     write_string ("Do");
-  else if (TREE_PURPOSE (spec))
+  else if (tree expr = TREE_PURPOSE (spec))
     {
-      gcc_assert (uses_template_parms (TREE_PURPOSE (spec)));
+      /* noexcept (expr)  */
+      gcc_assert (uses_template_parms (expr));
       write_string ("DO");
-      write_expression (TREE_PURPOSE (spec));
+      write_expression (expr);
       write_char ('E');
     }
   else
     {
+      /* throw (type-list) */
       write_string ("Dw");
       for (tree t = spec; t; t = TREE_CHAIN (t))
        write_type (TREE_VALUE (t));
@@ -829,7 +831,6 @@ write_encoding (const tree decl)
 
       if (tmpl)
        {
-         ++processing_template_decl;
          fn_type = get_mostly_instantiated_function_type (decl);
          /* FN_TYPE will not have parameter types for in-charge or
             VTT parameters.  Therefore, we pass NULL_TREE to
@@ -846,9 +847,6 @@ write_encoding (const tree decl)
       write_bare_function_type (fn_type,
                                mangle_return_type_p (decl),
                                d);
-
-      if (tmpl)
-       --processing_template_decl;
     }
 }
 
index 738afb621b20670d4bc6169d686efd5930a8e82b..6822d3dcd1eb4a96e10f0c1a5cf2ab61ec704db7 100644 (file)
@@ -1,3 +1,8 @@
+2017-01-18  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/79091
+       * g++.dg/pr79091.C: New.
+
 2017-01-17  Joe Seymour  <joe.s@somniumtech.com>
 
        * gcc.target/msp430/mul_f5_muldef.c: New test.
diff --git a/gcc/testsuite/g++.dg/pr79091.C b/gcc/testsuite/g++.dg/pr79091.C
new file mode 100644 (file)
index 0000000..ad8cf5a
--- /dev/null
@@ -0,0 +1,25 @@
+// PR 79091 ICE mangling an unnamed enum in a tempate instantiation.
+
+enum  {
+  One = 1
+};
+
+template<int Options>
+class Matrix {};
+
+template<int Dim>
+Matrix<Dim ? One : 0> *Bar ()
+{
+  return 0;
+}
+
+template<int Opt> 
+Matrix<Opt> *Baz ()
+{
+  return 0;
+}
+
+bool Foo ()
+{
+  return Baz<1> () == Bar<1> ();
+}