/* Seed any using-directives so that we emit the relevant namespaces. */
for (tree udir : NAMESPACE_LEVEL (ns)->using_directives)
- if (TREE_CODE (udir) == USING_DECL && DECL_MODULE_EXPORT_P (udir))
+ if (TREE_CODE (udir) == USING_DECL && DECL_MODULE_PURVIEW_P (udir))
{
make_dependency (USING_DECL_DECLS (udir), depset::EK_NAMESPACE);
- count++;
+ if (DECL_MODULE_EXPORT_P (udir))
+ count++;
}
if (count)
tree parent = parent_dep->get_entity ();
for (auto udir : NAMESPACE_LEVEL (parent)->using_directives)
{
- if (TREE_CODE (udir) != USING_DECL || !DECL_MODULE_EXPORT_P (udir))
+ if (TREE_CODE (udir) != USING_DECL || !DECL_MODULE_PURVIEW_P (udir))
continue;
+ bool exported = DECL_MODULE_EXPORT_P (udir);
tree target = USING_DECL_DECLS (udir);
depset *target_dep = table.find_dependency (target);
gcc_checking_assert (target_dep);
dump () && dump ("Writing using-directive in %N for %N",
parent, target);
+ sec.u (exported);
write_namespace (sec, parent_dep);
write_namespace (sec, target_dep);
++num;
for (unsigned ix = 0; ix != num; ++ix)
{
+ bool exported = sec.u ();
tree parent = read_namespace (sec);
tree target = read_namespace (sec);
if (sec.get_overrun ())
break;
dump () && dump ("Read using-directive in %N for %N", parent, target);
- add_using_namespace (parent, target);
+ if (exported || is_module () || is_partition ())
+ add_using_namespace (parent, target);
}
dump.outdent ();
namespace gmf::blah {}
namespace gmf::other {}
+using namespace gmf::other; // not emitted
export module b;
export import a;
using namespace a;
}
-// { dg-final { scan-lang-dump {Using-directives 3} module } }
+// { dg-final { scan-lang-dump {Using-directives 4} module } }
// { dg-final { scan-lang-dump {Writing using-directive in '::b' for '::a'} module } }
// { dg-final { scan-lang-dump {Writing using-directive in '::b' for '::gmf::blah'} module } }
// { dg-final { scan-lang-dump {Writing namespace:[0-9]* '::gmf::blah', public} module } }
// { dg-final { scan-lang-dump-not {Writing namespace:[0-9]* '::gmf::other'} module } }
+// { dg-final { scan-lang-dump-not {Writing using-directive in '::' for '::gmf::other'} module } }