diff options
author | Nathaniel Shead <nathanieloshead@gmail.com> | 2025-09-01 21:28:03 +1000 |
---|---|---|
committer | Nathaniel Shead <nathanieloshead@gmail.com> | 2025-09-04 17:42:25 +1000 |
commit | 03505e5b93e635907ed5ef7edac11da4026655e2 (patch) | |
tree | fffac6da189064c3b4f6cb2fc83f61eb5e2fe4ed /gcc | |
parent | 6ce76052aeaa3370243909b62c87bfdcb243b885 (diff) | |
download | gcc-03505e5b93e635907ed5ef7edac11da4026655e2.zip gcc-03505e5b93e635907ed5ef7edac11da4026655e2.tar.gz gcc-03505e5b93e635907ed5ef7edac11da4026655e2.tar.bz2 |
c++/modules: Mark implicit inline namespaces as purview [PR121724]
When we push an existing namespace within the module purview for the
first time, we also need to mark any parent inline namespaces as purview
to not confuse the streaming logic.
PR c++/121724
gcc/cp/ChangeLog:
* name-lookup.cc (push_namespace): Mark inline namespace
contexts as purview if needed.
gcc/testsuite/ChangeLog:
* g++.dg/modules/namespace-12_a.C: New test.
* g++.dg/modules/namespace-12_b.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/name-lookup.cc | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/modules/namespace-12_a.C | 17 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/modules/namespace-12_b.C | 6 |
3 files changed, 26 insertions, 0 deletions
diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc index ba62467..f5e8050 100644 --- a/gcc/cp/name-lookup.cc +++ b/gcc/cp/name-lookup.cc @@ -9273,6 +9273,9 @@ push_namespace (tree name, bool make_inline) gcc_checking_assert (!(tree)slot || (tree)slot == ctx); slot = ctx; } + + if (module_purview_p ()) + DECL_MODULE_PURVIEW_P (ctx) = true; } } diff --git a/gcc/testsuite/g++.dg/modules/namespace-12_a.C b/gcc/testsuite/g++.dg/modules/namespace-12_a.C new file mode 100644 index 0000000..a432626 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/namespace-12_a.C @@ -0,0 +1,17 @@ +// PR c++/121724 +// { dg-additional-options "-fmodules -Wno-global-module" } +// { dg-module-cmi foo } + +module; +namespace A { + inline namespace X { + namespace B { + } + } +} +export module foo; +export namespace A { + namespace B { + struct S {}; + } +} diff --git a/gcc/testsuite/g++.dg/modules/namespace-12_b.C b/gcc/testsuite/g++.dg/modules/namespace-12_b.C new file mode 100644 index 0000000..8c429ba --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/namespace-12_b.C @@ -0,0 +1,6 @@ +// PR c++/121724 +// { dg-additional-options "-fmodules" } + +import foo; +using T = A::B::S; +using T = A::X::B::S; |