Passed regtest (so far just modules.exp) on x86_64-pc-linux-gnu.
I'll push this as obvious in 24 hours if full bootstrap and regtest
pass, unless there are any issues raised.
-- >8 --
The assertion failure in the PR is due to the implicit using-directive
for the anonymous namespace not being considered imported, because
make_namespace_finish calls add_using_namespace without propagating
'from_import'.
PR c++/123393
gcc/cp/ChangeLog:
* name-lookup.cc (make_namespace_finish): Pass from_import to
add_using_namespace.
gcc/testsuite/ChangeLog:
* g++.dg/modules/namespace-18_a.C: New test.
* g++.dg/modules/namespace-18_b.C: New test.
Signed-off-by: Nathaniel Shead <[email protected]>
---
gcc/cp/name-lookup.cc | 3 ++-
gcc/testsuite/g++.dg/modules/namespace-18_a.C | 9 +++++++++
gcc/testsuite/g++.dg/modules/namespace-18_b.C | 9 +++++++++
3 files changed, 20 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/g++.dg/modules/namespace-18_a.C
create mode 100644 gcc/testsuite/g++.dg/modules/namespace-18_b.C
diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
index ff738f15d93..5d93c13265d 100644
--- a/gcc/cp/name-lookup.cc
+++ b/gcc/cp/name-lookup.cc
@@ -9288,7 +9288,8 @@ make_namespace_finish (tree ns, tree *slot, bool
from_import = false)
/* An unnamed namespace implicitly has a using-directive inserted so
that its contents are usable in the surrounding context. */
if (!DECL_NAMESPACE_INLINE_P (ns) && !DECL_NAME (ns))
- add_using_namespace (NAMESPACE_LEVEL (ctx)->using_directives, ns);
+ add_using_namespace (NAMESPACE_LEVEL (ctx)->using_directives, ns,
+ from_import);
}
/* NS is a possibly-imported namespace that is now needed for
diff --git a/gcc/testsuite/g++.dg/modules/namespace-18_a.C
b/gcc/testsuite/g++.dg/modules/namespace-18_a.C
new file mode 100644
index 00000000000..08a90285077
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/namespace-18_a.C
@@ -0,0 +1,9 @@
+// PR c++/123393
+// { dg-additional-options "-fmodules" }
+// { dg-module-cmi fmt }
+
+export module fmt;
+namespace fmt {
+ export template <typename T> void format(T);
+ namespace {}
+}
diff --git a/gcc/testsuite/g++.dg/modules/namespace-18_b.C
b/gcc/testsuite/g++.dg/modules/namespace-18_b.C
new file mode 100644
index 00000000000..4f6f7019742
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/namespace-18_b.C
@@ -0,0 +1,9 @@
+// PR c++123393
+// { dg-additional-options "-fmodules" }
+// { dg-module-cmi m }
+
+export module m;
+import fmt;
+inline void use() {
+ fmt::format("");
+}
--
2.51.0