[NFC] Add two tests for C++ modules
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>
Thu, 16 Feb 2023 08:24:37 +0000 (16:24 +0800)
committerChuanqi Xu <yedeng.yd@linux.alibaba.com>
Thu, 16 Feb 2023 09:02:04 +0000 (17:02 +0800)
One test for checking the decls in language linkage shouldn't be
discarded and can be mangled correctly.

Another one for checking we can't export again in an export decl.

clang/test/Modules/export-in-another-export.cppm [new file with mode: 0644]
clang/test/Modules/language-linkage.cppm [new file with mode: 0644]

diff --git a/clang/test/Modules/export-in-another-export.cppm b/clang/test/Modules/export-in-another-export.cppm
new file mode 100644 (file)
index 0000000..38cb4d6
--- /dev/null
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -std=c++20 %s -fsyntax-only -verify
+export module M;
+export { // expected-note {{export block begins here}}
+    export int foo() { return 43; } // expected-error {{export declaration appears within another export declaration}}
+}
diff --git a/clang/test/Modules/language-linkage.cppm b/clang/test/Modules/language-linkage.cppm
new file mode 100644 (file)
index 0000000..bf7982c
--- /dev/null
@@ -0,0 +1,18 @@
+// Make sure that the declarations inside the language linkage can
+// be generated correctly.
+//
+// RUN: rm -fr %t
+// RUN: mkdir %t
+//
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %s -emit-module-interface -o %t/M.pcm
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/M.pcm -S -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+export module M;
+
+extern "C++" {
+void foo() {} 
+}
+
+extern "C" void bar() {}
+
+// CHECK: define {{.*}}@bar(
+// CHECK: define {{.*}}@_Z3foov(