diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 14895bc65850c8683370e0df7b95edf4403db783..05913861e06e10087b744217f45beeb63f5aa28d 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -7381,6 +7381,8 @@ inline bool module_attach_p ()
 
 inline bool named_module_purview_p ()
 { return named_module_p () && module_purview_p (); }
+inline bool named_module_attach_p ()
+{ return named_module_p () && module_attach_p (); }
 
 /* We're currently exporting declarations.  */
 inline bool module_exporting_p ()
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index dbc3df24e77f2b17bb65d6fecae946225109942d..7a97b867199190b5a708195c64bae1aafbfb8966 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -6092,10 +6092,10 @@ start_decl (const cp_declarator *declarator,
     {
       /* A function-scope decl of some namespace-scope decl.  */
       DECL_LOCAL_DECL_P (decl) = true;
-      if (named_module_purview_p ())
+      if (named_module_attach_p ())
 	error_at (declarator->id_loc,
-		  "block-scope extern declaration %q#D not permitted"
-		  " in module purview", decl);
+		  "block-scope extern declaration %q#D must not be"
+		  " attached to a named module", decl);
     }
 
   /* Enter this declaration into the symbol table.  Don't push the plain
@@ -18907,10 +18907,10 @@ grokmethod (cp_decl_specifier_seq *declspecs,
   check_template_shadow (fndecl);
 
   /* p1779 ABI-Isolation makes inline not a default for in-class
-     definitions in named module purview.  If the user explicitly
+     definitions attached to a named module.  If the user explicitly
      made it inline, grokdeclarator will already have done the right
      things.  */
-  if ((!named_module_purview_p ()
+  if ((!named_module_attach_p ()
        || flag_module_implicit_inline
       /* Lambda's operator function remains inline.  */
        || LAMBDA_TYPE_P (DECL_CONTEXT (fndecl)))
diff --git a/gcc/testsuite/g++.dg/modules/block-decl-1_a.C b/gcc/testsuite/g++.dg/modules/block-decl-1_a.C
new file mode 100644
index 0000000000000000000000000000000000000000..e7ffc6291926f79dde445398d160f0cb64564359
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/block-decl-1_a.C
@@ -0,0 +1,9 @@
+// { dg-additional-options "-fmodules-ts" }
+// { dg-module-cmi bla }
+
+export module bla;
+
+export extern "C++" inline void fun() {
+  void oops();  // { dg-bogus "block-scope extern declaration" }
+  oops();
+}
diff --git a/gcc/testsuite/g++.dg/modules/block-decl-1_b.C b/gcc/testsuite/g++.dg/modules/block-decl-1_b.C
new file mode 100644
index 0000000000000000000000000000000000000000..c0d724f25ac0039930095afd85e38aabb2dd712c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/block-decl-1_b.C
@@ -0,0 +1,10 @@
+// { dg-module-do link }
+// { dg-additional-options "-fmodules-ts" }
+
+import bla;
+
+void oops() {}
+
+int main() {
+  fun();
+}
diff --git a/gcc/testsuite/g++.dg/modules/block-decl-2.C b/gcc/testsuite/g++.dg/modules/block-decl-2.C
new file mode 100644
index 0000000000000000000000000000000000000000..974e26f9b7aea1600efd2d59dffdcbb220f31812
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/block-decl-2.C
@@ -0,0 +1,21 @@
+// { dg-additional-options "-fmodules-ts" }
+// { dg-module-cmi !mod }
+
+export module mod;
+
+namespace {
+  void internal() {}
+}
+
+export extern "C++" auto foo() {
+  struct X {
+    // `foo` is not attached to a named module, and as such
+    // `X::f` should be implicitly `inline` here
+    void f() {  // { dg-error "references internal linkage entity" }
+      internal();
+    }
+  };
+  return X{};
+}
+
+// { dg-prune-output "failed to write compiled module" }