Fix class conflict between using-declaration and class definition
Corrects C++ name lookup to distinguish between a class using-declaration and a class definition, resolving a conflict.
GCC now correctly handles conflicts between a class using declaration and a subsequent class definition. Previously, the compiler treated these as a redefinition rather than a conflict between distinct declaration types. This fix ensures that name lookup accurately identifies these as separate kinds of declarations, resolving issues reported in PR115806 and improving diagnostic messages for related test cases.
In Details
The name lookup functions lookup_and_check_tag in decl.cc and lookup_elaborated_type in name-lookup.cc have been adjusted. The issue stemmed from a class using declaration followed by a class definition, which should be treated as a conflict rather than a redefinition. This change moves the stripping of using context from lookup_elaborated_type to lookup_and_check_tag to correctly differentiate these scenarios, thereby fixing PR115806 and improving diagnostic accuracy for related test cases.
- using-declaration
- In C++, a declaration that brings names from a namespace or a base class into the current scope, often used to simplify access to members or base class components.
- class definition
- In C++, the declaration that provides the members (data and functions) of a class. It specifies the complete structure of the class.
- name lookup
- The process by which the compiler determines which identifier (variable, function, type, etc.) is being referred to in the source code, based on the current scope and visibility rules.
- PR115806
- Problem Report 115806: A bug report filed against GCC detailing a specific issue that has been fixed by this commit.