c++: lambda in concept [PR105652]
authorJason Merrill <jason@redhat.com>
Fri, 27 May 2022 02:43:05 +0000 (22:43 -0400)
committerJason Merrill <jason@redhat.com>
Tue, 31 May 2022 19:31:03 +0000 (15:31 -0400)
commit102a1472ab393c89bd74c06ff92bef55fa61812c
treee1a621d25004f1a44153701870256a6a5661a1cf
parentd81be519fd6547654f1eda6976e95524db7d39b7
c++: lambda in concept [PR105652]

We currently check satisfaction in the context of the constrained
declaration (which may be wrong, see PR104111).  When checking C<int>
for S<int>, we currently substitute into the lambda in the context of
S<T> (rather than S<int>, which seems wrong if the above isn't wrong), so
the new closure type thinks its context is S<T>, which confuses debug
output.  For the moment, let's work around all of this by overriding the
context of the closure.

PR c++/105652

gcc/cp/ChangeLog:

* pt.cc (tsubst_lambda_expr): Don't let a namespace-scope lambda
instantiate into a class-scope lambda.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-lambda20.C: New test.
gcc/cp/pt.cc
gcc/testsuite/g++.dg/cpp2a/concepts-lambda20.C [new file with mode: 0644]