[clang] f8d5f0e - [NFC] Add two tests for C++ modules

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 16 01:02:52 PST 2023


Author: Chuanqi Xu
Date: 2023-02-16T17:02:04+08:00
New Revision: f8d5f0e53b04040cebbba639530133b261a4432f

URL: https://github.com/llvm/llvm-project/commit/f8d5f0e53b04040cebbba639530133b261a4432f
DIFF: https://github.com/llvm/llvm-project/commit/f8d5f0e53b04040cebbba639530133b261a4432f.diff

LOG: [NFC] Add two tests for C++ modules

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.

Added: 
    clang/test/Modules/export-in-another-export.cppm
    clang/test/Modules/language-linkage.cppm

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/clang/test/Modules/export-in-another-export.cppm b/clang/test/Modules/export-in-another-export.cppm
new file mode 100644
index 000000000000..38cb4d6c4a8c
--- /dev/null
+++ b/clang/test/Modules/export-in-another-export.cppm
@@ -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
index 000000000000..bf7982cd9207
--- /dev/null
+++ b/clang/test/Modules/language-linkage.cppm
@@ -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(


        


More information about the cfe-commits mailing list