]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: constrained auto in lambda using outer tparms [PR103706]
authorPatrick Palka <ppalka@redhat.com>
Tue, 8 Feb 2022 13:46:13 +0000 (08:46 -0500)
committerPatrick Palka <ppalka@redhat.com>
Tue, 12 Apr 2022 23:32:38 +0000 (19:32 -0400)
commit6eb8eb51a827a349cd6acce5f16ffef31d8934b1
tree972a53d59e15d604017a8cd2c1060228d41895ad
parent12b11107edfcde6a16ec397a9120687a14254215
c++: constrained auto in lambda using outer tparms [PR103706]

Here we're crashing during satisfaction of the lambda's placeholder type
constraints because the constraints depend on the template arguments
from the enclosing scope, which aren't part of the lambda's DECL_TI_ARGS.

This patch fixes this by making do_auto_deduction consider the
"regenerating" template arguments of a lambda for satisfaction,
mirroring what's done in satisfy_declaration_constraints.

PR c++/103706

gcc/cp/ChangeLog:

* constraint.cc (satisfy_declaration_constraints): Use
lambda_regenerating_args instead.
* cp-tree.h (lambda_regenerating_args): Declare.
* pt.c (lambda_regenerating_args): Define, split out from
satisfy_declaration_constraints.
(do_auto_deduction): Use lambda_regenerating_args to obtain the
full set of outer template arguments for satisfaction when
inside a lambda.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-lambda18.C: New test.

(cherry picked from commit 34ba3d9a2bf72742b1c150a2dd17d10e3e3f0964)
gcc/cp/constraint.cc
gcc/cp/cp-tree.h
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp2a/concepts-lambda18.C [new file with mode: 0644]