In this test since r17-472 we issue a bogus "not declared in this scope"
error when parsing the requires because we failed to pushdecl. Xobj
parameters reuse the default argument field (in _parameter_declaration)
so we also have to check this_identifier.
PR c++/125330
gcc/cp/ChangeLog:
* parser.cc (cp_parser_parameter_declaration_list): Also
pushdecl when parameter->default_argument is this_identifier.
gcc/testsuite/ChangeLog:
* g++.dg/cpp23/explicit-obj-basic8.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
/* If we saw a default argument, we've already pushed this decl.
(An ill-formed default argument should have been parsed to
error_mark_node.) */
- else if (!parameter->default_argument)
+ else if (!parameter->default_argument
+ || parameter->default_argument == this_identifier)
decl = pushdecl (decl);
}
--- /dev/null
+// PR c++/125330
+// { dg-do compile { target c++23 } }
+
+struct T {
+ template<typename Self>
+ void foo(this Self const &x) requires requires { x.bar(); }
+ { x.bar(); }
+};