]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: lambda in concept [PR118698]
authorJason Merrill <jason@redhat.com>
Tue, 8 Apr 2025 19:53:34 +0000 (15:53 -0400)
committerJason Merrill <jason@redhat.com>
Wed, 9 Apr 2025 02:09:59 +0000 (22:09 -0400)
commit94438ca82792063abf05823326695af25ab02d17
tree06775074cb10a688319dc13c659d7a43e58f3053
parent6ed8c17c2bce631ae370d93164ceb6c1b5adf925
c++: lambda in concept [PR118698]

When normalizing is_foo for <T>, we get to normalizing
callable<decltype(...),T> for <T,foo>, which means substituting <T,foo> into
<decltype(...),T>.

Since r14-9938, because in_template_context is false we return the lambda
unchanged, just with LAMBDA_EXPR_EXTRA_ARGS set, so the closure type still
refers to the is_specialization_of tparms in its CLASSTYPE_TEMPLATE_INFO.

So then in normalize_atom caching find_template_parameters walks over the
parameter mapping; any_template_parm_r walks into the TREE_TYPE of a
LAMBDA_EXPR without considering EXTRA_ARGS and finds a template parm from
the wrong parameter list.

But since r15-3530 we expect to set tf_partial when substituting with
dependent arguments, so we should set that when normalizing.  And then
tf_partial causes TREE_STATIC to be set on the EXTRA_ARGS, meaning that
those args will replace all the template parms in the rest of the lambda, so
we can walk just the EXTRA_ARGS and ignore the rest.

PR c++/118698

gcc/cp/ChangeLog:

* constraint.cc (struct norm_info): Add tf_partial.
* pt.cc (any_template_parm_r): Handle LAMBDA_EXPR_EXTRA_ARGS.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-lambda22.C: New test.
gcc/cp/constraint.cc
gcc/cp/pt.cc
gcc/testsuite/g++.dg/cpp2a/concepts-lambda22.C [new file with mode: 0644]