]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++/modules: Find non-exported reachable decls when instantiating friend classes...
authorNathaniel Shead <nathanieloshead@gmail.com>
Mon, 21 Apr 2025 09:58:03 +0000 (19:58 +1000)
committerNathaniel Shead <nathanieloshead@gmail.com>
Tue, 22 Apr 2025 07:25:46 +0000 (17:25 +1000)
commit948ea8766780f7e44f39ccde3f2436ac2fec80da
tree6494d382be855114fc87d78c3bb8808b08064457
parent6e0ffa9e8f36223700ff0cef30ba14305e8a8074
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 <nathanieloshead@gmail.com>
gcc/cp/name-lookup.cc
gcc/testsuite/g++.dg/modules/tpl-friend-18_a.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/tpl-friend-18_b.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/tpl-friend-18_c.C [new file with mode: 0644]