From: Adam Butcher Date: Sat, 8 Mar 2014 09:33:12 +0000 (+0000) Subject: re PR c++/60033 ([c++1y] ICE in retrieve_specialization while compiling recursive... X-Git-Tag: releases/gcc-4.9.0~525 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c74dc2ad6a8cba31b324b7d14a633522d937af3;p=thirdparty%2Fgcc.git re PR c++/60033 ([c++1y] ICE in retrieve_specialization while compiling recursive generic lambda) Fix PR c++/60033 PR c++/60033 * pt.c (tsubst_copy): When retrieving a capture pack from a generic lambda, remove the lambda's own template argument list prior to fetching the specialization. PR c++/60033 * g++.dg/cpp1y/pr60033.C: New testcase. From-SVN: r208427 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 07ac2b27f0aa..b48bb47d0bd0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2014-03-08 Adam Butcher + PR c++/60033 + * pt.c (tsubst_copy): When retrieving a capture pack from a generic + lambda, remove the lambda's own template argument list prior to fetching + the specialization. + PR c++/60393 * parser.c (cp_parser_parameter_declaration_clause): Move generic function template unwinding on error into a more general location, ... diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d4d54b8984d8..5afe0fdabc7e 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -12565,14 +12565,22 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl) { /* Check for a local specialization set up by tsubst_pack_expansion. */ - tree r = retrieve_local_specialization (t); - if (r) + if (tree r = retrieve_local_specialization (t)) { if (TREE_CODE (r) == ARGUMENT_PACK_SELECT) r = ARGUMENT_PACK_SELECT_ARG (r); return r; } + /* When retrieving a capture pack from a generic lambda, remove the + lambda call op's own template argument list from ARGS. Only the + template arguments active for the closure type should be used to + retrieve the pack specialization. */ + if (LAMBDA_FUNCTION_P (current_function_decl) + && (template_class_depth (DECL_CONTEXT (t)) + != TMPL_ARGS_DEPTH (args))) + args = strip_innermost_template_args (args, 1); + /* Otherwise return the full NONTYPE_ARGUMENT_PACK that tsubst_decl put in the hash table. */ return retrieve_specialization (t, args, 0); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9a0b752e001b..f29b5a427d06 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2014-03-08 Adam Butcher + PR c++/60033 + * g++.dg/cpp1y/pr60033.C: New testcase. + PR c++/60393 * g++.dg/cpp1y/pr60393.C: New testcase. diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60033.C b/gcc/testsuite/g++.dg/cpp1y/pr60033.C new file mode 100644 index 000000000000..8194bec24dbc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr60033.C @@ -0,0 +1,20 @@ +// PR c++/60033 +// { dg-options -std=c++1y } + +template +auto f(T&&... ts) +{ + return sizeof...(ts); +} + +template +auto g(T&&... ts) { + return [&] (auto v) { + return f(ts...); + }; +} + +int main() +{ + return g(1,2,3,4)(5) == 4 ? 0 : 1; +}