From eaccea2afa9be40d1d976292da8450cb36439d5f Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 25 Jun 2012 23:42:34 -0400 Subject: [PATCH] re PR c++/53498 (Compiler crashes during C++11 template magic compilation) PR c++/53498 PR c++/53305 * pt.c (tsubst_decl) [PARM_DECL]: Don't recurse into DECL_CHAIN if cp_unevaluated_operand is set. (tsubst_copy) [PARM_DECL]: Don't copy before tsubsting. From-SVN: r188973 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 13 ++++--------- gcc/testsuite/ChangeLog | 7 +++++++ gcc/testsuite/g++.dg/cpp0x/decltype38.C | 17 +++++++++++++++++ gcc/testsuite/g++.dg/cpp0x/variadic132.C | 6 +++--- 5 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/decltype38.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2d321b0005e..e80d3dc0e2e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 2012-06-25 Jason Merrill + PR c++/53498 + PR c++/53305 + * pt.c (tsubst_decl) [PARM_DECL]: Don't recurse into DECL_CHAIN + if cp_unevaluated_operand is set. + (tsubst_copy) [PARM_DECL]: Don't copy before tsubsting. + PR c++/52988 * typeck.c (decay_conversion): Don't discard side-effects from expressions of nullptr_t. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index ad7134b4d97..7e1c46f77c3 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -10497,7 +10497,9 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) DECL_CHAIN (prev_r) = r; } - if (DECL_CHAIN (t)) + /* If cp_unevaluated_operand is set, we're just looking for a + single dummy parameter, so don't keep going. */ + if (DECL_CHAIN (t) && !cp_unevaluated_operand) DECL_CHAIN (r) = tsubst (DECL_CHAIN (t), args, complain, DECL_CHAIN (t)); @@ -12078,8 +12080,6 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl) if (r == NULL_TREE) { - tree c; - /* We get here for a use of 'this' in an NSDMI. */ if (DECL_NAME (t) == this_identifier && at_function_scope_p () @@ -12090,12 +12090,7 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl) declaration (such as in a late-specified return type). Just make a dummy decl, since it's only used for its type. */ gcc_assert (cp_unevaluated_operand != 0); - /* We copy T because want to tsubst the PARM_DECL only, - not the following PARM_DECLs that are chained to T. */ - c = copy_node (t); - r = tsubst_decl (c, args, complain); - if (r == NULL_TREE) - return error_mark_node; + r = tsubst_decl (t, args, complain); /* Give it the template pattern as its context; its true context hasn't been instantiated yet and this is good enough for mangling. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b4f21e7493e..a85b990ee8d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2012-06-25 Jason Merrill + + PR c++/53498 + PR c++/53305 + * g++.dg/cpp0x/decltype38.C: New. + * g++.dg/cpp0x/variadic132.C: Remove dg-error. + 2012-06-25 Janis Johnson * lib/target-supports-dg.exp (testname-for-summary): New. diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype38.C b/gcc/testsuite/g++.dg/cpp0x/decltype38.C new file mode 100644 index 00000000000..97ebb33a031 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype38.C @@ -0,0 +1,17 @@ +// PR c++/53498 +// { dg-do compile { target c++11 } } + +template +struct B +{ + template + static + void b(const U& u, const Args&... args, + decltype(u.f(args...)) dummy) + { + } +}; + +int main() { + B b; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic132.C b/gcc/testsuite/g++.dg/cpp0x/variadic132.C index f50c7a659f5..1b9c2868684 100644 --- a/gcc/testsuite/g++.dg/cpp0x/variadic132.C +++ b/gcc/testsuite/g++.dg/cpp0x/variadic132.C @@ -9,11 +9,11 @@ struct funct int operator()(argTs...); }; -template class test; +template struct test; template