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 <nathanieloshead@gmail.com>
/* 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
--- /dev/null
+// PR c++/123393
+// { dg-additional-options "-fmodules" }
+// { dg-module-cmi fmt }
+
+export module fmt;
+namespace fmt {
+ export template <typename T> void format(T);
+ namespace {}
+}
--- /dev/null
+// PR c++123393
+// { dg-additional-options "-fmodules" }
+// { dg-module-cmi m }
+
+export module m;
+import fmt;
+inline void use() {
+ fmt::format("");
+}