On 10/30/19 7:20 AM, Jeff Chapman wrote:
Hello,

Attached is a patch that adds parsing of the optional requires-clause in a
lambda-expression and lambda-declarator. Additionally, shorthand constraints
from the template-parameter-list are now actually applied and constrain the
synthesized operator().

Previously we were not parsing the requires clauses at all and not saving the
shorthand constraints in the place expected by grokfndecl.

The trailing requires-clause is now also used to suppress synthesis of the
conversion to function pointer for non-capturing non-generic lambdas as per
expr.prim.lambda.closure/7.

This includes a fix to template_class_depth. Previously it was computing the
wrong depth for lambdas in the initializer of a static member of a class
template, exhibited by the concepts-lambda4 test which currently fails on
trunk. The bug was causing grokfndecl to use the constraints from the template
class for the lambda.

gcc/cp/
2019-10-30  Jeff Chapman II  <jchap...@lock3software.com>

        PR c++/84810 - constraints on lambdas
        * lambda.c (maybe_add_lambda_conv_op): Do not synthesize
        conversion if the call operator does not satisfy its constraints.
        * parser.c (cp_parser_lambda_declarator_opt): Parse
        requires-clause on generic lambdas; combine with shorthand
        constraints. Parse trailing requires-clause and attach to the
        synthesized call operator.
        * pt.c (template_class_depth): Only inspect
        LAMBDA_TYPE_EXTRA_SCOPE if it is present. This fixes an
        incorrect depth calculation for lambdas inside the initializer
        of a static data member of a template class.

gcc/testsuite/
2019-10-30  Jeff Chapman II  <jchap...@lock3software.com>

        PR c++/84810 - constraints on lambdas
        * g++.dg/cpp2a/concepts-lambda2.C: New test.
        * g++.dg/cpp2a/concepts-lambda3.C: Ditto.
        * g++.dg/cpp2a/concepts-lambda4.C: Ditto.
        * g++.dg/cpp2a/concepts-pr84810.C: Ditto.

Bootstrapped and tested on x86_64-pc-linux-gnu.

Please let me know if there's any issues.

Applied, thanks.

Jason

Reply via email to