From 2c65d990eb80d25c2e040be14a2918a0311dc37c Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Wed, 18 Jan 2017 12:51:28 +0000 Subject: [PATCH] re PR c++/79091 (ICE in write_unnamed_type) 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 | 7 +++++++ gcc/cp/mangle.c | 14 ++++++-------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/pr79091.C | 25 +++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/g++.dg/pr79091.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a42454a478a..7733be7cc52 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2017-01-18 Nathan Sidwell + + 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 PR c++/70182 diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index d1b107cbb1d..033660f0091 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -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; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 738afb621b2..6822d3dcd1e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-01-18 Nathan Sidwell + + PR c++/79091 + * g++.dg/pr79091.C: New. + 2017-01-17 Joe Seymour * 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 index 00000000000..ad8cf5a43e5 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr79091.C @@ -0,0 +1,25 @@ +// PR 79091 ICE mangling an unnamed enum in a tempate instantiation. + +enum { + One = 1 +}; + +template +class Matrix {}; + +template +Matrix *Bar () +{ + return 0; +} + +template +Matrix *Baz () +{ + return 0; +} + +bool Foo () +{ + return Baz<1> () == Bar<1> (); +} -- 2.30.2