]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: lambda in requires outside template [PR99546]
authorJason Merrill <jason@redhat.com>
Wed, 29 Jan 2025 10:15:00 +0000 (05:15 -0500)
committerJason Merrill <jason@redhat.com>
Fri, 4 Apr 2025 20:31:59 +0000 (16:31 -0400)
commitecc2725d61f1b268b51a604543b6717185bebd34
treef01049445cbd8de9c107f4a1fb7e3158fdcb6223
parent49b6308d2596f7334011f84bae8d35d68c302a3c
c++: lambda in requires outside template [PR99546]

Since r10-7441 we set processing_template_decl in a requires-expression so
that we can use tsubst_expr to evaluate the requirements, but that confuses
lambdas terribly; begin_lambda_type silently returns error_mark_node and we
continue into other failures.  This patch clears processing_template_decl
again while we're defining the closure and op() function, so it only remains
set while parsing the introducer (i.e. any init-captures) and building the
resulting object.  This properly avoids trying to create another lambda in
tsubst_lambda_expr.

PR c++/99546
PR c++/113925
PR c++/106976
PR c++/109961
PR c++/117336

gcc/cp/ChangeLog:

* lambda.cc (build_lambda_object): Handle fake
requires-expr processing_template_decl.
* parser.cc (cp_parser_lambda_expression): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/lambda-requires2.C: New test.
* g++.dg/cpp2a/lambda-requires3.C: New test.
* g++.dg/cpp2a/lambda-requires4.C: New test.
* g++.dg/cpp2a/lambda-requires5.C: New test.

(cherry picked from commit 25992d8daff60726a247ec7850d540aed5335639)
gcc/cp/lambda.cc
gcc/cp/parser.cc
gcc/testsuite/g++.dg/cpp2a/lambda-requires2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/lambda-requires3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/lambda-requires4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/lambda-requires5.C [new file with mode: 0644]