We shouldn't need to be within the lambda body to look through it to the
enclosing non-static member function.
This change is a small subset of r16-970.
PR c++/120123
gcc/cp/ChangeLog:
* lambda.cc (nonlambda_method_basetype): Look through lambdas
even when current_class_ref is null.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-lambda24.C: New test.
tree
nonlambda_method_basetype (void)
{
- if (!current_class_ref)
- return NULL_TREE;
-
tree type = current_class_type;
if (!type || !LAMBDA_TYPE_P (type))
- return type;
+ return current_class_ref ? type : NULL_TREE;
while (true)
{
--- /dev/null
+// PR c++/120123
+// { dg-do compile { target c++20 } }
+
+struct H {
+ void member(int) {}
+ void call() {
+ [this]() {
+ [this](const auto& v)
+ requires requires { /*this->*/member(v); }
+ { return member(v); }(0);
+ };
+ }
+};