c++: > in lambda in template arg [PR107953]

As with PR116928, we need to set greater_than_is_operator_p within the
lambda delimiters.

	PR c++/107953

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_lambda_expression): Set
	greater_than_is_operator_p.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/lambda-targ18.C: New test.
This commit is contained in:
Jason Merrill
2025-08-24 05:15:01 -04:00
parent 6750f5902c
commit 00e8690ef0
2 changed files with 15 additions and 0 deletions

View File

@@ -11806,6 +11806,8 @@ cp_parser_lambda_expression (cp_parser* parser,
it now. */
push_deferring_access_checks (dk_no_deferred);
auto gr = make_temp_override (parser->greater_than_is_operator_p, true);
if (!consteval_block_p)
{
cp_parser_lambda_introducer (parser, lambda_expr);

View File

@@ -0,0 +1,13 @@
// PR c++/107953
// { dg-do compile { target c++20 } }
template<auto F>
struct Foo {};
Foo<[](){ return 1 >= 0; }> foo1{};
Foo<[](){ return (1 > 0); }> foo2{};
Foo<[](){ return 1 > 0; }> foo3{};
Foo<[g = 1 > 0]{ return g; }> foo4{};