From f8d5f0e53b04040cebbba639530133b261a4432f Mon Sep 17 00:00:00 2001 From: Chuanqi Xu Date: Thu, 16 Feb 2023 16:24:37 +0800 Subject: [PATCH] [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. --- clang/test/Modules/export-in-another-export.cppm | 5 +++++ clang/test/Modules/language-linkage.cppm | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 clang/test/Modules/export-in-another-export.cppm create mode 100644 clang/test/Modules/language-linkage.cppm 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 0000000..38cb4d6 --- /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 0000000..bf7982c --- /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( -- 2.7.4