diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
index 15b5fba6297..e58f3b5cb4d 100644
--- a/gcc/cp/name-lookup.cc
+++ b/gcc/cp/name-lookup.cc
@@ -9089,7 +9089,6 @@ add_imported_namespace (tree ctx, tree name, location_t loc, unsigned import,
   if (!decl)
     {
       decl = make_namespace (ctx, name, loc, inline_p);
-      DECL_MODULE_IMPORT_P (decl) = true;
       make_namespace_finish (decl, slot, true);
     }
   else if (DECL_NAMESPACE_INLINE_P (decl) != inline_p)
diff --git a/gcc/testsuite/g++.dg/modules/indirect-1_b.C b/gcc/testsuite/g++.dg/modules/indirect-1_b.C
index c450fa9481c..39e9d21ab76 100644
--- a/gcc/testsuite/g++.dg/modules/indirect-1_b.C
+++ b/gcc/testsuite/g++.dg/modules/indirect-1_b.C
@@ -33,20 +33,20 @@ namespace bar
   export extern auto const Scoped_Const_Three = foo::Scoped::D;
 }
 
-// { dg-final { scan-lang-dump {Lazily binding '::foo@foo:.::frob'@'foo' section:} module } }
+// { dg-final { scan-lang-dump {Lazily binding '::foo::frob'@'foo' section:} module } }
 // { dg-final { scan-lang-dump-not {namespace:-[0-9]* namespace_decl:'::foo'} module } }
-// { dg-final { scan-lang-dump {Wrote import:-[0-9]* function_decl:'::foo@foo:.::frob@foo:.'@foo} module } }
+// { dg-final { scan-lang-dump {Wrote import:-[0-9]* function_decl:'::foo::frob@foo:.'@foo} module } }
 
-// { dg-final { scan-lang-dump {Lazily binding '::foo@foo:.::X'@'foo' section:} module } }
-// { dg-final { scan-lang-dump {Wrote import:-[0-9]* type_decl:'::foo@foo:.::X@foo:.'@foo} module } }
+// { dg-final { scan-lang-dump {Lazily binding '::foo::X'@'foo' section:} module } }
+// { dg-final { scan-lang-dump {Wrote import:-[0-9]* type_decl:'::foo::X@foo:.'@foo} module } }
 
-// { dg-final { scan-lang-dump {Lazily binding '::foo@foo:.::Y'@'foo' section:} module } }
-// { dg-final { scan-lang-dump {Wrote import:-[0-9]* type_decl:'::foo@foo:.::Y@foo:.'@foo} module } }
+// { dg-final { scan-lang-dump {Lazily binding '::foo::Y'@'foo' section:} module } }
+// { dg-final { scan-lang-dump {Wrote import:-[0-9]* type_decl:'::foo::Y@foo:.'@foo} module } }
 
-// { dg-final { scan-lang-dump {Lazily binding '::foo@foo:.::B'@'foo' section:} module } }
-// { dg-final { scan-lang-dump-not {Lazily binding '::foo@foo:.::C@foo:.'@'foo' section:} module } }
-// { dg-final { scan-lang-dump {Lazily binding '::foo@foo:.::Scoped'@'foo' section:} module } }
-// { dg-final { scan-lang-dump-not {Lazily binding '::foo@foo:.::Scoped@foo:.::[ABCD]'@'foo' section:} module } }
+// { dg-final { scan-lang-dump {Lazily binding '::foo::B'@'foo' section:} module } }
+// { dg-final { scan-lang-dump-not {Lazily binding '::foo::C@foo:.'@'foo' section:} module } }
+// { dg-final { scan-lang-dump {Lazily binding '::foo::Scoped'@'foo' section:} module } }
+// { dg-final { scan-lang-dump-not {Lazily binding '::foo::Scoped@foo:.::[ABCD]'@'foo' section:} module } }
 
 // { dg_final { scan-lang-dump {Wrote named import:-[0-9]* const_decl:'::foo::Plain@\(foo\)::C'@foo} module } }
 // { dg_final { scan-lang-dump {Wrote named import:-[0-9]* const_decl:'::foo::Plain@\(foo\)::B'@foo} module } }
diff --git a/gcc/testsuite/g++.dg/modules/indirect-1_c.C b/gcc/testsuite/g++.dg/modules/indirect-1_c.C
index 73d5974c846..8ac0654a1eb 100644
--- a/gcc/testsuite/g++.dg/modules/indirect-1_c.C
+++ b/gcc/testsuite/g++.dg/modules/indirect-1_c.C
@@ -23,27 +23,27 @@ int main ()
   return 0;
 }
 
-// { dg-final { scan-lang-dump {Lazily binding '::bar@bar:.::frob'@'bar' section:} module } }
+// { dg-final { scan-lang-dump {Lazily binding '::bar::frob'@'bar' section:} module } }
 // { dg-final { scan-lang-dump {>Loading entity foo\[14\] section:4} module } }
-// { dg-final { scan-lang-dump {Named:-[0-9]* namespace_decl:'::foo@foo:1'@foo} module } }
-// { dg-final { scan-lang-dump {Imported:-[0-9]* function_decl:'::foo@foo:.::frob@foo:.'@foo} module } }
+// { dg-final { scan-lang-dump {Named:-[0-9]* namespace_decl:'::foo'@foo} module } }
+// { dg-final { scan-lang-dump {Imported:-[0-9]* function_decl:'::foo::frob@foo:.'@foo} module } }
 
-// { dg-final { scan-lang-dump {Lazily binding '::bar@bar:.::quux'@'bar' section:} module } }
+// { dg-final { scan-lang-dump {Lazily binding '::bar::quux'@'bar' section:} module } }
 // { dg-final { scan-lang-dump {>Loading entity foo\[1\] section:1} module } }
-// { dg-final { scan-lang-dump {Imported:-[0-9]* type_decl:'::foo@foo:.::X@foo:.'@foo} module } }
+// { dg-final { scan-lang-dump {Imported:-[0-9]* type_decl:'::foo::X@foo:.'@foo} module } }
 
-// { dg-final { scan-lang-dump {Lazily binding '::bar@bar:.::Z'@'bar' section:} module } }
+// { dg-final { scan-lang-dump {Lazily binding '::bar::Z'@'bar' section:} module } }
 // { dg-final { scan-lang-dump {>Loading entity foo\[8\] section:2} module } }
-// { dg-final { scan-lang-dump {Imported:-[0-9]* type_decl:'::foo@foo:.::Y@foo:.'@foo} module } }
-// { dg-final { scan-lang-dump {Read member:-[0-9]* field_decl:'::foo@foo:.::Y@foo:.::_vptr.Y'} module } }
-// { dg-final { scan-lang-dump {Imported:-[0-9]* function_decl:'::foo@foo:.::Y@foo:.::frob@foo:.'@foo} module } }
+// { dg-final { scan-lang-dump {Imported:-[0-9]* type_decl:'::foo::Y@foo:.'@foo} module } }
+// { dg-final { scan-lang-dump {Read member:-[0-9]* field_decl:'::foo::Y@foo:.::_vptr.Y'} module } }
+// { dg-final { scan-lang-dump {Imported:-[0-9]* function_decl:'::foo::Y@foo:.::frob@foo:.'@foo} module } }
 
-// { dg-final { scan-lang-dump {Lazily binding '::bar@bar:.::Plain_One'@'bar' section:} module } }
+// { dg-final { scan-lang-dump {Lazily binding '::bar::Plain_One'@'bar' section:} module } }
 // { dg-final { scan-lang-dump {>Loading entity foo\[13\] section:3} module } }
-// { dg-final { scan-lang-dump {Lazily binding '::bar@bar:.::Scoped_One'@'bar' section} module } }
+// { dg-final { scan-lang-dump {Lazily binding '::bar::Scoped_One'@'bar' section} module } }
 // { dg-final { scan-lang-dump {>Loading entity foo\[15\] section:5} module } }
-// { dg-final { scan-lang-dump-not {Lazily binding '::foo@foo:.::[ABC]'@'foo' section:} module } }
-// { dg-final { scan-lang-dump-not {Lazily binding '::foo@foo:.::Scoped@\(foo\)::[ABC]'@'foo' section:} module } }
+// { dg-final { scan-lang-dump-not {Lazily binding '::foo::[ABC]'@'foo' section:} module } }
+// { dg-final { scan-lang-dump-not {Lazily binding '::foo::Scoped@\(foo\)::[ABC]'@'foo' section:} module } }
 
-// { dg-final { scan-lang-dump {Lazily binding '::bar@bar:.::Plain_Const_Three'@'bar' section:} module } }
-// { dg-final { scan-lang-dump {Lazily binding '::bar@bar:.::Scoped_Const_Three'@'bar' section} module } }
+// { dg-final { scan-lang-dump {Lazily binding '::bar::Plain_Const_Three'@'bar' section:} module } }
+// { dg-final { scan-lang-dump {Lazily binding '::bar::Scoped_Const_Three'@'bar' section} module } }
diff --git a/gcc/testsuite/g++.dg/modules/indirect-2_b.C b/gcc/testsuite/g++.dg/modules/indirect-2_b.C
index 16e060a2210..763899ed3e4 100644
--- a/gcc/testsuite/g++.dg/modules/indirect-2_b.C
+++ b/gcc/testsuite/g++.dg/modules/indirect-2_b.C
@@ -17,15 +17,15 @@ namespace bar
   }
 }
 
-// { dg-final { scan-lang-dump {Lazily binding '::foo@foo:.::frob'@'foo' section} module } }
-// { dg-final { scan-lang-dump {Wrote import:-[0-9]* template_decl:'::foo@foo:.::template frob@foo:.'@foo} module } }
-// { dg-final { scan-lang-dump {Writing:-[0-9]*'s decl spec merge key \(specialization\) function_decl:'::foo@foo:.::frob<0x0>'} module } }
+// { dg-final { scan-lang-dump {Lazily binding '::foo::frob'@'foo' section} module } }
+// { dg-final { scan-lang-dump {Wrote import:-[0-9]* template_decl:'::foo::template frob@foo:.'@foo} module } }
+// { dg-final { scan-lang-dump {Writing:-[0-9]*'s decl spec merge key \(specialization\) function_decl:'::foo::frob<0x0>'} module } }
 
-// { dg-final { scan-lang-dump {Lazily binding '::foo@foo:.::X'@'foo' section:} module } }
-// { dg-final { scan-lang-dump {Wrote import:-[0-9]* template_decl:'::foo@foo:.::template X@foo:.'@foo} module } }
+// { dg-final { scan-lang-dump {Lazily binding '::foo::X'@'foo' section:} module } }
+// { dg-final { scan-lang-dump {Wrote import:-[0-9]* template_decl:'::foo::template X@foo:.'@foo} module } }
 
-// { dg-final { scan-lang-dump {Cluster members:\n  \[0\]=specialization definition '::foo@foo:.::X<0x0>'\n  \[1\]=specialization declaration '::foo@foo:.::X<0x0>::__conv_op <0x0>'\n  \[2\]=specialization declaration '::foo@foo:.::X<0x0>::X<0x0>'\n(  \[.\]=[^\n]* '\n)*} module } }
-// { dg-final { scan-lang-dump {Writing:-[0-9]*'s type spec merge key \(specialization\) type_decl:'::foo@foo:.::X<0x0>'} module } }
-// { dg-final { scan-lang-dump {Depset:. specialization entity:. type_decl:'::foo@foo:.::X<0x0>'} module } }
-// { dg-final { scan-lang-dump {Writing:-[0-9]*'s type spec merge key \(specialization\) type_decl:'::foo@foo:.::X<0x0>'} module } }
-// { dg-final { scan-lang-dump {Wrote purview:-[0-9]* type_decl:'::foo@foo:.::X<0x0>'} module } }
+// { dg-final { scan-lang-dump {Cluster members:\n  \[0\]=specialization definition '::foo::X<0x0>'\n  \[1\]=specialization declaration '::foo::X<0x0>::__conv_op <0x0>'\n  \[2\]=specialization declaration '::foo::X<0x0>::X<0x0>'\n(  \[.\]=[^\n]* '\n)*} module } }
+// { dg-final { scan-lang-dump {Writing:-[0-9]*'s type spec merge key \(specialization\) type_decl:'::foo::X<0x0>'} module } }
+// { dg-final { scan-lang-dump {Depset:. specialization entity:. type_decl:'::foo::X<0x0>'} module } }
+// { dg-final { scan-lang-dump {Writing:-[0-9]*'s type spec merge key \(specialization\) type_decl:'::foo::X<0x0>'} module } }
+// { dg-final { scan-lang-dump {Wrote purview:-[0-9]* type_decl:'::foo::X<0x0>'} module } }
diff --git a/gcc/testsuite/g++.dg/modules/indirect-2_c.C b/gcc/testsuite/g++.dg/modules/indirect-2_c.C
index a5cf44ba785..855c9d1f025 100644
--- a/gcc/testsuite/g++.dg/modules/indirect-2_c.C
+++ b/gcc/testsuite/g++.dg/modules/indirect-2_c.C
@@ -13,13 +13,13 @@ int main ()
   return 0;
 }
 
-// { dg-final { scan-lang-dump {Lazily binding '::bar@bar:.::frob'@'bar' section:} module } }
+// { dg-final { scan-lang-dump {Lazily binding '::bar::frob'@'bar' section:} module } }
 // { dg-final { scan-lang-dump {>Loading entity foo\[4\] section:2} module } }
-// { dg-final { scan-lang-dump {Imported:-[0-9]* template_decl:'::foo@foo:.::template frob@foo:.'@foo} module } }
+// { dg-final { scan-lang-dump {Imported:-[0-9]* template_decl:'::foo::template frob@foo:.'@foo} module } }
 // { dg-final { scan-lang-dump-not {Wrote mergeable} module } }
 
 
-// { dg-final { scan-lang-dump {Lazily binding '::bar@bar:.::quux'@'bar' section:} module } }
+// { dg-final { scan-lang-dump {Lazily binding '::bar::quux'@'bar' section:} module } }
 // { dg-final { scan-lang-dump {>Loading entity foo\[1\] section:1} module } }
-// { dg-final { scan-lang-dump {Imported:-[0-9]* template_decl:'::foo@foo:.::template X@foo:.'@foo} module } }
-// { dg-final { scan-lang-dump {Read:-[0-9]* function_decl:'::foo@foo:.::frob<0x0>'} module } }
+// { dg-final { scan-lang-dump {Imported:-[0-9]* template_decl:'::foo::template X@foo:.'@foo} module } }
+// { dg-final { scan-lang-dump {Read:-[0-9]* function_decl:'::foo::frob<0x0>'} module } }
diff --git a/gcc/testsuite/g++.dg/modules/indirect-3_b.C b/gcc/testsuite/g++.dg/modules/indirect-3_b.C
index 038b01ecab7..a111bfbf11a 100644
--- a/gcc/testsuite/g++.dg/modules/indirect-3_b.C
+++ b/gcc/testsuite/g++.dg/modules/indirect-3_b.C
@@ -17,14 +17,14 @@ namespace bar
   }
 }
 
-// { dg-final { scan-lang-dump {Lazily binding '::foo@foo:.::X'@'foo' section} module } }
-// { dg-final { scan-lang-dump {Wrote import:-[0-9]* template_decl:'::foo@foo:.::X@foo:.::template frob@foo:.'@foo} module } }
+// { dg-final { scan-lang-dump {Lazily binding '::foo::X'@'foo' section} module } }
+// { dg-final { scan-lang-dump {Wrote import:-[0-9]* template_decl:'::foo::X@foo:.::template frob@foo:.'@foo} module } }
 
-// { dg-final { scan-lang-dump {Lazily binding '::foo@foo:.::TPL'@'foo' section} module } }
-// { dg-final { scan-lang-dump {Wrote import:-[0-9]* template_decl:'::foo@foo:.::template TPL@foo:.'@foo} module } }
+// { dg-final { scan-lang-dump {Lazily binding '::foo::TPL'@'foo' section} module } }
+// { dg-final { scan-lang-dump {Wrote import:-[0-9]* template_decl:'::foo::template TPL@foo:.'@foo} module } }
 
-// { dg-final { scan-lang-dump {Cluster members:\n  \[0\]=specialization definition '::foo@foo:.::TPL<0x0>'\n  \[1\]=specialization definition '::foo@foo:.::TPL<0x0>::frob<0x0>'\n  \[2\]=specialization declaration '::foo@foo:.::TPL<0x0>::TPL<0x0>'} module } }
+// { dg-final { scan-lang-dump {Cluster members:\n  \[0\]=specialization definition '::foo::TPL<0x0>'\n  \[1\]=specialization definition '::foo::TPL<0x0>::frob<0x0>'\n  \[2\]=specialization declaration '::foo::TPL<0x0>::TPL<0x0>'} module } }
 
-// { dg-final { scan-lang-dump {Cluster members:\n  \[0\]=specialization definition '::foo@foo:.::X@foo:.::frob<0x0>'} module } }
-// { dg-final { scan-lang-dump {Writing:-[0-9]*'s type spec merge key \(specialization\) type_decl:'::foo@foo:.::TPL<0x0>'} module } }
-// { dg-final { scan-lang-dump {Writing:-[0-9]*'s decl spec merge key \(specialization\) function_decl:'::foo@foo:.::X@foo:.::frob<0x0>'} module } }
+// { dg-final { scan-lang-dump {Cluster members:\n  \[0\]=specialization definition '::foo::X@foo:.::frob<0x0>'} module } }
+// { dg-final { scan-lang-dump {Writing:-[0-9]*'s type spec merge key \(specialization\) type_decl:'::foo::TPL<0x0>'} module } }
+// { dg-final { scan-lang-dump {Writing:-[0-9]*'s decl spec merge key \(specialization\) function_decl:'::foo::X@foo:.::frob<0x0>'} module } }
diff --git a/gcc/testsuite/g++.dg/modules/indirect-3_c.C b/gcc/testsuite/g++.dg/modules/indirect-3_c.C
index ec2fc768373..0178ffb17f4 100644
--- a/gcc/testsuite/g++.dg/modules/indirect-3_c.C
+++ b/gcc/testsuite/g++.dg/modules/indirect-3_c.C
@@ -13,12 +13,12 @@ int main ()
   return 0;
 }
 
-// { dg-final { scan-lang-dump {Lazily binding '::bar@bar:.::quux'@'bar' section:} module } }
+// { dg-final { scan-lang-dump {Lazily binding '::bar::quux'@'bar' section:} module } }
 // { dg-final { scan-lang-dump {>Loading entity foo\[5\] section:2} module } }
-// { dg-final { scan-lang-dump {Imported:-[0-9]* template_decl:'::foo@foo:.::X@foo:.::template frob@foo:.'@foo} module } }
+// { dg-final { scan-lang-dump {Imported:-[0-9]* template_decl:'::foo::X@foo:.::template frob@foo:.'@foo} module } }
 // { dg-final { scan-lang-dump-not {Instantiation:-[0-9]* function_decl:'::foo::X@foo:.::frob@.()<0x0>'} module } }
 
-// { dg-final { scan-lang-dump {Lazily binding '::bar@bar:.::toto'@'bar' section:} module } }
+// { dg-final { scan-lang-dump {Lazily binding '::bar::toto'@'bar' section:} module } }
 // { dg-final { scan-lang-dump {>Loading entity foo\[.\] section:1} module } }
-// { dg-final { scan-lang-dump {Imported:-[0-9]* template_decl:'::foo@foo:.::template TPL@foo:.'@foo} module } }
-// { dg-final { scan-lang-dump {Reading definition type_decl '::foo@foo:.::TPL@bar:.<0x0>'} module } }
+// { dg-final { scan-lang-dump {Imported:-[0-9]* template_decl:'::foo::template TPL@foo:.'@foo} module } }
+// { dg-final { scan-lang-dump {Reading definition type_decl '::foo::TPL@bar:.<0x0>'} module } }
diff --git a/gcc/testsuite/g++.dg/modules/indirect-4_b.C b/gcc/testsuite/g++.dg/modules/indirect-4_b.C
index 8c51ce8097b..702991d4d24 100644
--- a/gcc/testsuite/g++.dg/modules/indirect-4_b.C
+++ b/gcc/testsuite/g++.dg/modules/indirect-4_b.C
@@ -12,11 +12,11 @@ namespace bar
   }
 }
 
-// { dg-final { scan-lang-dump {Lazily binding '::foo@foo:.::TPL'@'foo' section:} module } }
-// { dg-final { scan-lang-dump {Wrote import:-[0-9]* template_decl:'::foo@foo:.::template TPL@foo:.'@foo} module } }
+// { dg-final { scan-lang-dump {Lazily binding '::foo::TPL'@'foo' section:} module } }
+// { dg-final { scan-lang-dump {Wrote import:-[0-9]* template_decl:'::foo::template TPL@foo:.'@foo} module } }
 
-// { dg-final { scan-lang-dump {Cluster members:\n  \[0\]=specialization definition '::foo@foo:.::TPL<0x1>'\n  \[1\]=specialization declaration '::foo@foo:.::TPL<0x1>::template frob<#unnamed#>'\n  \[2\]=specialization declaration '::foo@foo:.::TPL<0x1>::TPL<0x1>'\n(  \[.\]=[^\n]* '\n)*} module } }
-// { dg-final { scan-lang-dump {Cluster members:\n  \[0\]=specialization definition '::foo@foo:.::TPL<0x1>::frob<0x2>'} module } }
-// { dg-final { scan-lang-dump {Writing:-[0-9]*'s type spec merge key \(specialization\) type_decl:'::foo@foo:.::TPL<0x1>'} module } }
-// { dg-final { scan-lang-dump {Wrote purview:-[0-9]* type_decl:'::foo@foo:.::TPL<0x1>'} module } }
-// { dg-final { scan-lang-dump {Writing:-[0-9]*'s decl spec merge key \(specialization\) function_decl:'::foo@foo:.::TPL<0x1>::frob<0x2>'} module } }
+// { dg-final { scan-lang-dump {Cluster members:\n  \[0\]=specialization definition '::foo::TPL<0x1>'\n  \[1\]=specialization declaration '::foo::TPL<0x1>::template frob<#unnamed#>'\n  \[2\]=specialization declaration '::foo::TPL<0x1>::TPL<0x1>'\n(  \[.\]=[^\n]* '\n)*} module } }
+// { dg-final { scan-lang-dump {Cluster members:\n  \[0\]=specialization definition '::foo::TPL<0x1>::frob<0x2>'} module } }
+// { dg-final { scan-lang-dump {Writing:-[0-9]*'s type spec merge key \(specialization\) type_decl:'::foo::TPL<0x1>'} module } }
+// { dg-final { scan-lang-dump {Wrote purview:-[0-9]* type_decl:'::foo::TPL<0x1>'} module } }
+// { dg-final { scan-lang-dump {Writing:-[0-9]*'s decl spec merge key \(specialization\) function_decl:'::foo::TPL<0x1>::frob<0x2>'} module } }
diff --git a/gcc/testsuite/g++.dg/modules/indirect-4_c.C b/gcc/testsuite/g++.dg/modules/indirect-4_c.C
index d55a2216fb3..206891fe07a 100644
--- a/gcc/testsuite/g++.dg/modules/indirect-4_c.C
+++ b/gcc/testsuite/g++.dg/modules/indirect-4_c.C
@@ -9,9 +9,9 @@ int main ()
   return 0;
 }
 
-// { dg-final { scan-lang-dump {Lazily binding '::bar@bar:.::quux'@'bar' section:} module } }
+// { dg-final { scan-lang-dump {Lazily binding '::bar::quux'@'bar' section:} module } }
 // { dg-final { scan-lang-dump {>Loading entity foo\[.\] section:1} module } }
-// { dg-final { scan-lang-dump {Imported:-[0-9]* template_decl:'::foo@foo:.::template TPL@foo:.'@foo} module } }
+// { dg-final { scan-lang-dump {Imported:-[0-9]* template_decl:'::foo::template TPL@foo:.'@foo} module } }
 
-// { dg-final { scan-lang-dump {Reading definition function_decl '::foo@foo:.::TPL@bar:.<0x1>::frob@bar:.<0x2>'} module } }
-// { dg-final { scan-lang-dump {Reading definition type_decl '::foo@foo:.::TPL@bar:.<0x1>'} module } }
+// { dg-final { scan-lang-dump {Reading definition function_decl '::foo::TPL@bar:.<0x1>::frob@bar:.<0x2>'} module } }
+// { dg-final { scan-lang-dump {Reading definition type_decl '::foo::TPL@bar:.<0x1>'} module } }
diff --git a/gcc/testsuite/g++.dg/modules/namespace-5_a.C b/gcc/testsuite/g++.dg/modules/namespace-5_a.C
new file mode 100644
index 00000000000..491eb1a1b45
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/namespace-5_a.C
@@ -0,0 +1,6 @@
+// PR c++/100707
+// { dg-additional-options "-fmodules-ts" }
+// { dg-module-cmi A }
+
+export module A;
+export namespace A {}
diff --git a/gcc/testsuite/g++.dg/modules/namespace-5_b.C b/gcc/testsuite/g++.dg/modules/namespace-5_b.C
new file mode 100644
index 00000000000..76a43bff207
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/namespace-5_b.C
@@ -0,0 +1,7 @@
+// PR c++/100707
+// { dg-additional-options "-fmodules-ts" }
+// { dg-module-cmi A.B }
+
+export module A.B;
+import A;
+export namespace A::B {}
diff --git a/gcc/testsuite/g++.dg/modules/namespace-5_c.C b/gcc/testsuite/g++.dg/modules/namespace-5_c.C
new file mode 100644
index 00000000000..93ccbf0c3a7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/namespace-5_c.C
@@ -0,0 +1,5 @@
+// PR c++/100707
+// { dg-additional-options "-fmodules-ts" }
+
+import A.B;
+namespace A::B {}
