diff options
author | Jason Merrill <jason@redhat.com> | 2024-11-12 16:04:52 -0500 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2024-11-14 11:34:06 -0500 |
commit | 835530f4ee416f5ea20b3611f61f790c641d5cd3 (patch) | |
tree | 2957714dda5a5162d55c8ebee8a142a512e5920c /gcc | |
parent | e8ebc91615a088b47db6e6b000b7b154b267ea0e (diff) | |
download | gcc-835530f4ee416f5ea20b3611f61f790c641d5cd3.zip gcc-835530f4ee416f5ea20b3611f61f790c641d5cd3.tar.gz gcc-835530f4ee416f5ea20b3611f61f790c641d5cd3.tar.bz2 |
c++: fix namespace alias export
This affected std::views in module std.
gcc/cp/ChangeLog:
* name-lookup.cc (do_namespace_alias): set_originating_module after
pushdecl.
gcc/testsuite/ChangeLog:
* g++.dg/modules/namespace-7_a.C: New test.
* g++.dg/modules/namespace-7_b.C: New test.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/name-lookup.cc | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/modules/namespace-7_a.C | 14 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/modules/namespace-7_b.C | 8 |
3 files changed, 28 insertions, 2 deletions
diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc index 72fd485..2dca57a 100644 --- a/gcc/cp/name-lookup.cc +++ b/gcc/cp/name-lookup.cc @@ -6620,9 +6620,13 @@ do_namespace_alias (tree alias, tree name_space) DECL_EXTERNAL (alias) = 1; DECL_CONTEXT (alias) = FROB_CONTEXT (current_scope ()); TREE_PUBLIC (alias) = TREE_PUBLIC (DECL_CONTEXT (alias)); - set_originating_module (alias); - pushdecl (alias); + alias = pushdecl (alias); + + if (!DECL_P (alias) || !DECL_NAMESPACE_ALIAS (alias)) + return; + + set_originating_module (alias); /* Emit debug info for namespace alias. */ if (!building_stmt_list_p ()) diff --git a/gcc/testsuite/g++.dg/modules/namespace-7_a.C b/gcc/testsuite/g++.dg/modules/namespace-7_a.C new file mode 100644 index 0000000..dc2717d --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/namespace-7_a.C @@ -0,0 +1,14 @@ +// { dg-additional-options "-fmodules -Wno-global-module" } + +module; + +namespace B { int i; } +namespace C = B; + +export module foo; +// { dg-module-cmi foo } + +export { + namespace B { using B::i; } + namespace C = B; +} diff --git a/gcc/testsuite/g++.dg/modules/namespace-7_b.C b/gcc/testsuite/g++.dg/modules/namespace-7_b.C new file mode 100644 index 0000000..21abf94 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/namespace-7_b.C @@ -0,0 +1,8 @@ +// { dg-additional-options "-fmodules" } + +import foo; + +int main() +{ + C::i = 42; +} |