]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: lambda in pack expansion [PR115378]
authorPatrick Palka <ppalka@redhat.com>
Fri, 7 Jun 2024 16:12:30 +0000 (12:12 -0400)
committerPatrick Palka <ppalka@redhat.com>
Fri, 7 Jun 2024 16:12:30 +0000 (12:12 -0400)
commit5c761395402a730535983a5e49ef1775561ebc61
treed21e2b34b51212f658e2de914b38d14385346743
parenta3d68b5155018817dd7eef5abbaeadf3959b8e5e
c++: lambda in pack expansion [PR115378]

Here find_parameter_packs_r is incorrectly treating the 'auto' return
type of a lambda as a parameter pack due to Concepts-TS specific logic
added in r6-4517, leading to confusion later when expanding the pattern.

Since we intend on removing Concepts TS support soon anyway, this patch
fixes this by restricting the problematic logic with flag_concepts_ts.
Doing so revealed that add_capture was relying on this logic to set
TEMPLATE_TYPE_PARAMETER_PACK for the 'auto' type of an pack expansion
init-capture, which we now need to do explicitly.

PR c++/115378

gcc/cp/ChangeLog:

* lambda.cc (lambda_capture_field_type): Set
TEMPLATE_TYPE_PARAMETER_PACK on the auto type of an init-capture
pack expansion.
* pt.cc (find_parameter_packs_r) <case TEMPLATE_TYPE_PARM>:
Restrict TEMPLATE_TYPE_PARAMETER_PACK promotion with
flag_concepts_ts.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/decltype-auto-103497.C: Adjust expected diagnostic.
* g++.dg/template/pr95672.C: Likewise.
* g++.dg/cpp2a/lambda-targ5.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/lambda.cc
gcc/cp/pt.cc
gcc/testsuite/g++.dg/cpp1y/decltype-auto-103497.C
gcc/testsuite/g++.dg/cpp2a/lambda-targ5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/pr95672.C