C++ class template instantiation needs enclosing scope for base clauses.
Fixes nested class template instantiation to correctly look up members in the enclosing scope for base class clauses.
When instantiating nested class templates, the compiler needs to look up members in the enclosing scope when processing base class clauses. A recent change removed scope handling around base clause substitution, which broke lookups for using-declarations. This commit restores the correct scope handling to ensure members from the enclosing class are properly brought into scope during nested class instantiation, fixing PR 82613.
In Details
The instantiate_class_template function in pt.cc previously removed scope handling around base-clause substitution. This commit reintroduces push_scope before base substitution and moves pop_scope to the end of the function, ensuring that members of an enclosing class are correctly found when instantiating a nested class template, addressing an issue with using-declarations in that context. This resolves PR 114804.
- class template instantiation
- The process of creating a concrete class from a template by providing specific types or values for its parameters. This is a core mechanism in C++ for generic programming.
- nested class
- A class defined within another class. The nested class has access to members of its enclosing class.
- using-declaration
- A C++ construct that introduces a name from a base class or namespace into the current scope, allowing it to be used without qualification.
- base-clause substitution
- In template instantiation, this refers to the process of replacing placeholder types in a base class specification with the actual types provided by the template arguments.