The issue in the PR is that we're checking if the binding entity for the
current TU matches the namespace we're pushing. In this case the slot
however is a STAT_HACK we created during 'maybe_record_mergeable_decl'
to indicate that the binding entity contains a global module binding.
Adding '|| (STAT_HACK_P ((tree) slot) && STAT_DECL ((tree) slot) == ns)'
should fix the assertion, but I think we want to just not build the
STAT_HACK for namespaces, as they'll always be global module regardless,
and cannot match with any other declaration, so there's no need for the
special flag.
PR c++/122995
gcc/cp/ChangeLog:
* name-lookup.cc (maybe_record_mergeable_decl): Don't build a
STAT_HACK for namespaces.
gcc/testsuite/ChangeLog:
* g++.dg/modules/namespace-17_a.C: New test.
* g++.dg/modules/namespace-17_b.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
(slot, name, is_attached ? BINDING_SLOT_PARTITION : BINDING_SLOT_GLOBAL,
true);
- if (!is_attached)
+ /* A namespace is always global module so there's no need to mark
+ the current binding slot as such. */
+ if (!is_attached && TREE_CODE (decl) != NAMESPACE_DECL)
{
binding_slot &orig
= BINDING_VECTOR_CLUSTER (*slot, 0).slots[BINDING_SLOT_CURRENT];
--- /dev/null
+// PR c++/122995
+// { dg-additional-options "-fmodules" }
+// { dg-module-cmi bug2 }
+
+export module bug2;
+namespace N {
+ namespace C { struct r3_cpo; } export extern inline C::r3_cpo const r3;
+}
--- /dev/null
+// PR c++/122995
+// { dg-additional-options "-fmodules" }
+// { dg-module-cmi bug }
+
+export module bug;
+import bug2;
+namespace N {
+ namespace C { struct r1_cpo; } export extern inline C::r1_cpo const r1;
+ namespace C { struct r2_cpo; } export extern inline C::r2_cpo const r2;
+}