[Bug c++/84810] [concepts][c++20] constraints of lambdas with explicit template parameters are not checked
jason at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Oct 31 02:32:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84810
--- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Thu Oct 31 02:31:48 2019
New Revision: 277655
URL: https://gcc.gnu.org/viewcvs?rev=277655&root=gcc&view=rev
Log:
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.
Added:
trunk/gcc/testsuite/g++.dg/cpp2a/concepts-lambda2.C
trunk/gcc/testsuite/g++.dg/cpp2a/concepts-lambda3.C
trunk/gcc/testsuite/g++.dg/cpp2a/concepts-lambda4.C
trunk/gcc/testsuite/g++.dg/cpp2a/concepts-pr84810.C
Modified:
trunk/gcc/cp/lambda.c
trunk/gcc/cp/parser.c
trunk/gcc/cp/pt.c
More information about the Gcc-bugs
mailing list