]> git.ipfire.org Git - thirdparty/gcc.git/commit
PR c++/84810 - constraints on lambdas
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 31 Oct 2019 02:31:48 +0000 (02:31 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 31 Oct 2019 02:31:48 +0000 (02:31 +0000)
commit5a9f187489127e242dfdae40dc03ceee56217b45
tree7f8442e216b2d8722a38b040707deedc3c3da7cd
parentcb46fcd51555b37165d65c667ee767a596b79217
PR c++/84810 - constraints on lambdas

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  <jchapman@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  <jchapman@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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@277655 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/cp/lambda.c
gcc/cp/parser.c
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp2a/concepts-lambda2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/concepts-lambda3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/concepts-lambda4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/concepts-pr84810.C [new file with mode: 0644]