diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 21fc85150c9..72e876cec18 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -13253,8 +13253,11 @@ depset::hash::add_binding_entity (tree decl, WMB_Flags flags, void *data_) data->met_namespace = true; if (data->hash->add_namespace_entities (decl, data->partitions)) { - /* It contains an exported thing, so it is exported. */ - gcc_checking_assert (DECL_MODULE_PURVIEW_P (decl)); + /* It contains an exported thing, so it is exported. + We used to assert DECL_MODULE_PURVIEW_P, but that fails for a + namespace like std::__exception_ptr which is never opened in + module purview; the exporting using finds another using. */ + DECL_MODULE_PURVIEW_P (decl) = true; DECL_MODULE_EXPORT_P (decl) = true; } diff --git a/gcc/testsuite/g++.dg/modules/using-20_a.C b/gcc/testsuite/g++.dg/modules/using-20_a.C new file mode 100644 index 00000000000..bb3bb6160f8 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-20_a.C @@ -0,0 +1,14 @@ +// { dg-additional-options "-fmodules-ts -fdump-lang-module -Wno-global-module" } +// { dg-final { scan-lang-dump {Writing definition '::foo::bar::baz'} module } } + +module; +namespace foo { + namespace bar { + struct baz { }; + } + using bar::baz; +} +export module foo; +namespace foo { + export using foo::baz; +}