c++: Allow template lambdas without lambda-declarator [PR97839]
authorMarek Polacek <polacek@redhat.com>
Tue, 17 Nov 2020 16:38:25 +0000 (11:38 -0500)
committerMarek Polacek <polacek@redhat.com>
Sat, 21 Nov 2020 20:35:14 +0000 (15:35 -0500)
commit78cd6a63ee67ed854fbe54dd7c0a500dc138459a
treebf7e0f1f965778ff911221099b83e465ddfccdd3
parentddaad23e2f49a91ab59f87f31b01e57439a3d6df
c++: Allow template lambdas without lambda-declarator [PR97839]

Our implementation of template lambdas incorrectly requires the optional
lambda-declarator.  This was probably required by an early draft of
generic lambdas, but now the production is [expr.prim.lambda.general]:

 lambda-expression:
    lambda-introducer lambda-declarator [opt] compound-statement
    lambda-introducer < template-parameter-list > requires-clause [opt]
  lambda-declarator [opt] compound-statement

Therefore, we should accept the following test.

gcc/cp/ChangeLog:

PR c++/97839
* parser.c (cp_parser_lambda_declarator_opt): Don't require ().

gcc/testsuite/ChangeLog:

PR c++/97839
* g++.dg/cpp2a/lambda-generic8.C: New test.
gcc/cp/parser.c
gcc/testsuite/g++.dg/cpp2a/lambda-generic8.C [new file with mode: 0644]