https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119863
--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Nathaniel Shead <nsh...@gcc.gnu.org>: https://gcc.gnu.org/g:948ea8766780f7e44f39ccde3f2436ac2fec80da commit r16-62-g948ea8766780f7e44f39ccde3f2436ac2fec80da Author: Nathaniel Shead <nathanielosh...@gmail.com> Date: Mon Apr 21 19:58:03 2025 +1000 c++/modules: Find non-exported reachable decls when instantiating friend classes [PR119863] In r15-9029-geb26b667518c95, we started checking for conflicting declarations with any reachable decl attached to the same originating module. This exposed the issue in the PR, where we would always create a new type even if a matching type existed in the original module. This patch reworks lookup_imported_hidden_friend to handle this case better, by first checking for any reachable decl in the attached module before looking in the mergeable decl slots. PR c++/119863 gcc/cp/ChangeLog: * name-lookup.cc (get_mergeable_namespace_binding): Remove no-longer-used function. (lookup_imported_hidden_friend): Also look for hidden imported decls in an attached decl's module. gcc/testsuite/ChangeLog: * g++.dg/modules/tpl-friend-18_a.C: New test. * g++.dg/modules/tpl-friend-18_b.C: New test. * g++.dg/modules/tpl-friend-18_c.C: New test. Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com>