Fix bogus error with xobj member function
Fixed a false positive error in C++ parsing related to xobj member functions and requires clauses.
This commit fixes a bug in the C++ parser that caused a spurious “not declared in this scope” error when parsing requires clauses with xobj parameters (explicit object parameters). The issue occurred because the parser failed to properly pushdecl when the parameter’s default argument was a this_identifier. This correction ensures that code using xobj member functions compiles without unexpected errors.
In Details
The fix addresses PR c++/125330 by modifying cp_parser_parameter_declaration_list in parser.cc. The parser now correctly handles this_identifier in the default_argument field of parameters, ensuring proper declaration pushing. This issue is specific to the parsing of requires clauses and interactions with xobj parameters, so it may not be immediately obvious to developers outside the C++ front end.
For Context
In C++, explicit object parameters (xobj) allow you to specify the object on which a member function should be called as a parameter. This commit fixes a bug in how GCC parses code that uses xobj parameters within requires clauses (which specify constraints on template arguments or function behavior). The bug caused the compiler to incorrectly report that a variable was not declared, even when it was. This fix ensures that the compiler correctly understands and compiles code using xobj parameters and requires clauses.