]> git.ipfire.org Git - thirdparty/gcc.git/commit
PR c++/90538 - multiple expansions of capture packs
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 31 Jul 2019 18:50:00 +0000 (18:50 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 31 Jul 2019 18:50:00 +0000 (18:50 +0000)
commit5c2419ef8c4ae3f3e5ebd6996c534404b86df2cd
treed87b3e8faad065950a5e60c3ced44c3a27fada8c
parent30ca2094de2977be13de5214d6347312852341fe
PR c++/90538 - multiple expansions of capture packs

Previously, with init-capture the type of the closure field was a
DECLTYPE_TYPE of the initializer.  But since each time we tsubst a lambda we
get a different lambda, that meant that if the initializer is a lambda, we'd
end up with different closure types in the field and initializer after
substitution (PR 87322).  We dealt with this by remembering the lambda
instantiation within each pack expansion element, using
local_specialization_stack to separate the elements.  But that broke this
testcase, because it lost lambda capture proxies that also use
local_specializations.

So, this patch removes the local_specializations changes from that patch and
fixes 87322 differently, by giving init-capture fields 'auto' type and doing
deduction later.  There's a bit of a kludge to get the right number of
fields by pretending that 'auto...' uses the parameter packs from the
initializer, but it does the trick.

* cp-tree.h (DECLTYPE_FOR_INIT_CAPTURE): Remove.
* lambda.c (add_capture): Copy parameter packs from init.
(lambda_capture_field_type): Always use auto for init-capture.
* pt.c (uses_parameter_packs): Return tree.
(tsubst) [DECLTYPE_TYPE]: Remove init-capture handling.
(gen_elem_of_pack_expansion_instantiation): Don't push
local_specialization_stack.
(prepend_one_capture): New.
(tsubst_lambda_expr): Use it.  Don't touch local_specializations.
(do_auto_deduction): Avoid redundant error.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@273944 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/lambda.c
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-variadic9.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/range-for19.C
gcc/testsuite/g++.dg/cpp1y/lambda-init16.C