aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/parser.cc3
-rw-r--r--gcc/testsuite/g++.dg/modules/lang-3_a.C17
-rw-r--r--gcc/testsuite/g++.dg/modules/lang-3_b.C18
-rw-r--r--gcc/testsuite/g++.dg/modules/lang-3_c.C12
4 files changed, 50 insertions, 0 deletions
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 84f379c..8969ed0 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -16189,6 +16189,8 @@ cp_parser_linkage_specification (cp_parser* parser, tree prefix_attr)
linkage = get_identifier (TREE_STRING_POINTER (linkage));
/* We're now using the new linkage. */
+ unsigned saved_module = module_kind;
+ module_kind &= ~MK_ATTACH;
push_lang_context (linkage);
/* Preserve the location of the innermost linkage specification,
@@ -16235,6 +16237,7 @@ cp_parser_linkage_specification (cp_parser* parser, tree prefix_attr)
/* We're done with the linkage-specification. */
pop_lang_context ();
+ module_kind = saved_module;
/* Restore location of parent linkage specification, if any. */
parser->innermost_linkage_specification_location = saved_location;
diff --git a/gcc/testsuite/g++.dg/modules/lang-3_a.C b/gcc/testsuite/g++.dg/modules/lang-3_a.C
new file mode 100644
index 0000000..1c6fa1f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/lang-3_a.C
@@ -0,0 +1,17 @@
+// { dg-additional-options "-fmodules-ts -Wno-pedantic" }
+module;
+# 4 __FILE__ 1
+void Quux ();
+# 6 "" 2
+export module bob;
+// { dg-module-cmi bob }
+
+extern "C++"
+{
+export void Bar () {}
+export void Quux ();
+void Baz () {}
+}
+
+// { dg-final { scan-assembler {_Z3Barv:} } }
+// { dg-final { scan-assembler {_Z3Bazv:} } }
diff --git a/gcc/testsuite/g++.dg/modules/lang-3_b.C b/gcc/testsuite/g++.dg/modules/lang-3_b.C
new file mode 100644
index 0000000..17300ec
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/lang-3_b.C
@@ -0,0 +1,18 @@
+// { dg-additional-options -fmodules-ts }
+import bob;
+
+void Foo ()
+{
+ Bar ();
+ Baz (); // { dg-error "was not declared" }
+ Quux ();
+}
+
+void Bar ();
+void Baz ();
+
+void Quux ()
+{
+ Bar ();
+ Baz ();
+}
diff --git a/gcc/testsuite/g++.dg/modules/lang-3_c.C b/gcc/testsuite/g++.dg/modules/lang-3_c.C
new file mode 100644
index 0000000..ca18db7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/lang-3_c.C
@@ -0,0 +1,12 @@
+// { dg-additional-options -fmodules-ts }
+module bob;
+
+void Foo ()
+{
+ Bar ();
+ Baz ();
+}
+
+extern "C++" void Bar ();
+extern "C++" void Baz ();
+