]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++/modules: Import purview using-directives in the same module [PR122279]
authorNathaniel Shead <nathanieloshead@gmail.com>
Wed, 15 Oct 2025 07:13:38 +0000 (18:13 +1100)
committerNathaniel Shead <nathanieloshead@gmail.com>
Sat, 18 Oct 2025 13:53:31 +0000 (00:53 +1100)
commit515045254f5dbdea5208035a0352acc12c381088
treec831e815ae9e49a98a7dad3e7a7321670059d815
parent75fb400d2950e1f743f133ece8fb3abe815faf13
c++/modules: Import purview using-directives in the same module [PR122279]

[namespace.qual] p1 says that a namespace nominated by a using-directive
is searched if the using-directive precedes that point.

[basic.lookup.general] p2 says that a declaration in a different TU
within a module purview is visible if either the declaration is
exported, or the other TU is part of the same module as the point of
lookup.  This patch implements the second half of that.

PR c++/122279

gcc/cp/ChangeLog:

* module.cc (depset::hash::add_namespace_entities): Seed any
purview using-decls.
(module_state::write_using_directives): Stream if the udir was
exported or not.
(module_state::read_using_directives): Add the using-directive
if it's either exported or part of this module.

gcc/testsuite/ChangeLog:

* g++.dg/modules/namespace-13_b.C: Adjust expected results.
* g++.dg/modules/namespace-13_c.C: Test non-exported
using-directive is not used.
* g++.dg/modules/namespace-14_a.C: New test.
* g++.dg/modules/namespace-14_b.C: New test.
* g++.dg/modules/namespace-14_c.C: New test.
* g++.dg/modules/namespace-14_d.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/module.cc
gcc/testsuite/g++.dg/modules/namespace-13_b.C
gcc/testsuite/g++.dg/modules/namespace-13_c.C
gcc/testsuite/g++.dg/modules/namespace-14_a.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/namespace-14_b.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/namespace-14_c.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/namespace-14_d.C [new file with mode: 0644]