https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121574
--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Nathaniel Shead <[email protected]>: https://gcc.gnu.org/g:f5db79b06eb85f715dc3180065cb326ed180ab23 commit r16-5049-gf5db79b06eb85f715dc3180065cb326ed180ab23 Author: Nathaniel Shead <[email protected]> Date: Sun Nov 2 15:58:39 2025 +1100 c++/modules: Complain on imported GMF TU-local entities in instantiation [PR121574] An unfortunate side effect of the previous patch is that even with -pedantic-errors, unless the user specifies -Wtemplate-names-tu-local when building the module interface there will be no diagnostic at all from instantiating a template that exposes global TU-local entities, either when building the module or its importer. This patch solves this by recognising imported TU-local dependencies, even if they weren't streamed as TU_LOCAL_ENTITY nodes. The warnings here are deliberately conservative for when we can be sure this was actually an imported TU-local entity; in particular, we bail on any TU-local entity that originated from a header module, without attempting to determine if the entity came via a named module first. PR c++/121574 gcc/cp/ChangeLog: * cp-tree.h (instantiating_tu_local_entity): Declare. * module.cc (is_tu_local_entity): Extract from depset::hash. (is_tu_local_value): Likewise. (has_tu_local_tmpl_arg): Likewise. (depset::hash::is_tu_local_entity): Remove. (depset::hash::has_tu_local_tmpl_arg): Remove. (depset::hash::is_tu_local_value): Remove. (instantiating_tu_local_entity): New function. (depset::hash::add_binding_entity): No longer go through depset::hash to check is_tu_local_entity. * pt.cc (complain_about_tu_local_entity): Remove. (tsubst): Use instantiating_tu_local_entity. (tsubst_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/modules/internal-17_b.C: Check for diagnostics when instantiating imported TU-local entities. Signed-off-by: Nathaniel Shead <[email protected]> Reviewed-by: Jason Merrill <[email protected]>
