]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++/modules: Support unnamed namespaces in header units
authorNathaniel Shead <nathanieloshead@gmail.com>
Fri, 6 Sep 2024 13:46:47 +0000 (23:46 +1000)
committerNathaniel Shead <nathanieloshead@gmail.com>
Fri, 20 Dec 2024 01:57:24 +0000 (12:57 +1100)
commiteebd8dfdc4f4a7f54b42f74c2e7f54f957930ecd
treea61e05143058082ca6ee4a3a35f2f942e8b42ede
parent0c2ae384326108fad5ca2713ad3c9b768162fe73
c++/modules: Support unnamed namespaces in header units

A header unit may contain unnamed namespaces, and those declarations
are exported (as with any declaration in a header unit).  This patch
ensures that such declarations are correctly handled.

The change to 'make_namespace_finish' is required so that if an unnamed
namespace is first seen by an import it is correctly handled within
'add_imported_namespace'.  I don't see any particular reason why
handling of unnamed namespaces here had to be handled separately outside
that function since these are the only two callers.

gcc/cp/ChangeLog:

* module.cc (depset::hash::add_binding_entity): Also walk
unnamed namespaces.
(module_state::write_namespaces): Adjust assertion.
* name-lookup.cc (push_namespace): Move anon using-directive
handling to...
(make_namespace_finish): ...here.

gcc/testsuite/ChangeLog:

* g++.dg/modules/internal-9_a.H: New test.
* g++.dg/modules/internal-9_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/module.cc
gcc/cp/name-lookup.cc
gcc/testsuite/g++.dg/modules/internal-9_a.H [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/internal-9_b.C [new file with mode: 0644]