c++/modules: Improve handling of friend template specializations in modules.
c++/modules: Fixes module handling for friend template specializations without prior declarations.
This change enhances C++ module support by correctly handling template information that uses an identifier as a template, specifically for friend template specializations that lack a prior declaration. This resolves an issue where certain sanity checks were too strict, preventing these cases from being processed correctly. New test cases are included to verify the fix.
In Details
c++/modules: handle tinfo with identifier as template [PR127207]
This commit relaxes two sanity checks in cp/module.cc (trees_out::decl_value and get_originating_module_decl) to accept IDENTIFIER_NODE as the TI_TEMPLATE for TEMPLATE_INFO structures. This is necessary to correctly handle friend template specializations like createFoo<T>() when createFoo itself has not yet been declared. Such cases are represented internally with IDENTIFIER_NODE for the template argument, which the previous checks did not anticipate, leading to errors when processing modules containing these…
- TEMPLATE_INFO
- An internal GCC data structure representing information about a C++ template.
- IDENTIFIER_NODE
- A GCC internal representation for an identifier, such as a variable or function name.
- TI_TEMPLATE
- A field within the TEMPLATE_INFO structure that points to the template itself.
- friend template specialization
- A declaration that makes a template a friend of a class or another template, allowing access to private members. A specialization occurs when a template is instantiated for a specific type or value.
- PR127207
- A problem report number in GCC's bug tracking system, indicating a specific issue that has been addressed by this commit.