diff options
author | Jason Merrill <jason@redhat.com> | 2021-04-02 11:05:46 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2021-04-02 12:46:54 -0400 |
commit | 2a26351b598242c2fbce95d2a0baacce0084aec6 (patch) | |
tree | 5eee86e5ccc2ea0657eeec2543dce1913473296c /gcc/cp/lambda.c | |
parent | f4e05eebd6aac6118cbd9e0a04c011b6ed682826 (diff) | |
download | gcc-2a26351b598242c2fbce95d2a0baacce0084aec6.zip gcc-2a26351b598242c2fbce95d2a0baacce0084aec6.tar.gz gcc-2a26351b598242c2fbce95d2a0baacce0084aec6.tar.bz2 |
c++: lambda pack init-capture within generic lambda
We represent the type of a pack init-capture as auto... with packs from the
initializer stuck into PACK_EXPANSION_PARAMETER_PACKS so that expanding it
produces the right number of elements. But when partially instantiating the
auto..., we were changing PACK_EXPANSION_PARAMETER_PACKS to refer to only
the auto itself. Fixed thus.
gcc/cp/ChangeLog:
PR c++/97938
* cp-tree.h (PACK_EXPANSION_AUTO_P): New.
* lambda.c (add_capture): Set it.
* pt.c (tsubst_pack_expansion): Handle it.
gcc/testsuite/ChangeLog:
PR c++/97938
* g++.dg/cpp2a/lambda-pack-init6.C: New test.
Diffstat (limited to 'gcc/cp/lambda.c')
-rw-r--r-- | gcc/cp/lambda.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index 421685c..b0fd6ec 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -606,8 +606,11 @@ add_capture (tree lambda, tree id, tree orig_init, bool by_reference_p, parameter pack in this context. We will want as many fields as we have elements in the expansion of the initializer, so use its packs instead. */ - PACK_EXPANSION_PARAMETER_PACKS (type) - = uses_parameter_packs (initializer); + { + PACK_EXPANSION_PARAMETER_PACKS (type) + = uses_parameter_packs (initializer); + PACK_EXPANSION_AUTO_P (type) = true; + } } /* Make member variable. */ |