]> gcc.gnu.org Git - gcc.git/commit
c++: lambdas inside constraints [PR92652]
authorPatrick Palka <ppalka@redhat.com>
Fri, 29 May 2020 13:40:40 +0000 (09:40 -0400)
committerPatrick Palka <ppalka@redhat.com>
Fri, 29 May 2020 13:44:13 +0000 (09:44 -0400)
commit020d86db8896f088435830595640e6fc21bc64ad
tree46a81ae2adc3ed593e8ae5b548f7b9bce73ceb2e
parente069285cdf457cc85070e522380c4e25b0d2ed25
c++: lambdas inside constraints [PR92652]

When parsing a constraint-expression, a requires-clause or a
requires-expression, we temporarily increment processing_template_decl
so that we always obtain template trees which we could later reduce via
substitution even when not inside a template.

But incrementing processing_template_decl when we're already inside a
template has the unintended side effect of shifting up the template
parameter levels of a lambda defined inside one of these constructs,
which leads to confusion later during substitution into the lambda.

This patch fixes this issue by incrementing processing_template_decl
during parsing of these constructs only if it is 0.

Passes 'make check-c++', and also tested by building cmcstl2, does this
look OK to commit after a full bootstrap/regtest?

gcc/cp/ChangeLog:

PR c++/92652
PR c++/93698
PR c++/94128
* parser.c (cp_parser_requires_clause_expression): Temporarily
increment processing_template_decl only if it is 0.
(cp_parser_constraint_expression): Likewise.
(cp_parser_requires_expression): Likewise.

gcc/testsuite/ChangeLog:

PR c++/92652
PR c++/93698
PR c++/94128
* g++.dg/cpp2a/concepts-lambda8.C: New test.
* g++.dg/cpp2a/concepts-lambda9.C: New test.
* g++.dg/cpp2a/concepts-lambda10.C: New test.
gcc/cp/parser.c
gcc/testsuite/g++.dg/cpp2a/concepts-lambda10.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/concepts-lambda8.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/concepts-lambda9.C [new file with mode: 0644]
This page took 0.06351 seconds and 6 git commands to generate.