aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/cp-tree.h2
-rw-r--r--gcc/cp/decl.cc10
-rw-r--r--gcc/testsuite/g++.dg/modules/block-decl-1_a.C9
-rw-r--r--gcc/testsuite/g++.dg/modules/block-decl-1_b.C10
-rw-r--r--gcc/testsuite/g++.dg/modules/block-decl-2.C21
5 files changed, 47 insertions, 5 deletions
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 14895bc..0591386 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 dbc3df2..7a97b86 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 0000000..e7ffc62
--- /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 0000000..c0d724f
--- /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 0000000..974e26f
--- /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" }