From d54888a3ebb141cdbb5e88ed7a3a2a54d24fc904 Mon Sep 17 00:00:00 2001 From: Chuanqi Xu Date: Thu, 16 Feb 2023 13:57:25 +0800 Subject: [PATCH] [Modules] Refactor modules-ts tests to use standard c++ modules We're going to remove the support for modules-ts. But there are a lot of tests which uses -fmodules-ts. We shouldn't remove them simply. This patch refactor these tests to use standard c++ modules. --- .../basic/basic.def.odr/p4.cppm} | 89 +++++++++++++-- clang/test/CXX/module/basic/basic.def.odr/p6.cppm | 124 +++++++++++++++++++++ .../basic/basic.link/module-declaration.cpp | 37 +++--- clang/test/CXX/module/basic/basic.link/p2.cppm | 73 ++++++++++++ clang/test/CXX/module/basic/basic.link/p3.cppm | 11 ++ .../module/basic/basic.search/module-import.cppm | 52 +++++++++ clang/test/CXX/module/codegen-basics.cppm | 16 +++ .../dcl.dcl/dcl.module/dcl.module.export/p1.cppm | 47 ++++++++ .../dcl.dcl/dcl.module/dcl.module.import/p1.cppm | 57 ++++++++++ .../dcl.module/dcl.module.interface/p1.cppm} | 12 +- clang/test/CXX/module/dcl.dcl/dcl.module/p1.cpp | 14 +++ .../dcl.dcl/dcl.module/p2.cpp | 2 +- .../dcl.dcl/dcl.module/p5.cpp | 14 ++- .../modules-ts/basic/basic.def.odr/p4/module.cpp | 39 ------- .../CXX/modules-ts/basic/basic.def.odr/p4/user.cpp | 21 ---- .../basic/basic.def.odr/p6/global-vs-module.cpp | 54 --------- .../basic/basic.def.odr/p6/module-vs-global.cpp | 19 ---- .../basic/basic.def.odr/p6/module-vs-module.cpp | 44 -------- .../CXX/modules-ts/basic/basic.link/p2/module.cpp | 17 --- .../CXX/modules-ts/basic/basic.link/p2/module.cppm | 29 ----- .../CXX/modules-ts/basic/basic.link/p2/other.cpp | 17 --- clang/test/CXX/modules-ts/basic/basic.link/p3.cppm | 11 -- .../basic/basic.search/module-import.cpp | 39 ------- clang/test/CXX/modules-ts/codegen-basics.cppm | 21 ---- .../dcl.dcl/dcl.module/dcl.module.export/p1.cpp | 40 ------- .../dcl.dcl/dcl.module/dcl.module.import/p1.cpp | 49 -------- .../test/CXX/modules-ts/dcl.dcl/dcl.module/p1.cpp | 14 --- clang/test/CodeGenCXX/cxx20-module-nested-1.cppm | 2 +- clang/test/CodeGenCXX/cxx20-module-nested-2.cppm | 2 +- clang/test/Driver/modules-ts.cpp | 40 ------- clang/test/Lexer/modules-ts.cpp | 11 -- clang/test/Modules/anon-linkage.cpp | 12 -- clang/test/Modules/anon-linkage.cppm | 21 ++++ clang/test/Modules/diag-flags.cpp | 44 ++++---- clang/test/Modules/diag-pragma.cpp | 9 +- clang/test/Modules/import-syntax.c | 5 - clang/test/Modules/mismatch-diagnostics.cpp | 18 +-- clang/test/Parser/cxx-modules-interface.cppm | 4 +- clang/test/SemaCXX/anonymous-union-export.cpp | 2 +- .../test/SemaCXX/{modules-ts.cppm => modules.cppm} | 22 ++-- clang/unittests/AST/DeclTest.cpp | 6 +- 41 files changed, 588 insertions(+), 572 deletions(-) rename clang/test/CXX/{modules-ts/basic/basic.def.odr/p4/module.cppm => module/basic/basic.def.odr/p4.cppm} (54%) create mode 100644 clang/test/CXX/module/basic/basic.def.odr/p6.cppm rename clang/test/CXX/{modules-ts => module}/basic/basic.link/module-declaration.cpp (53%) create mode 100644 clang/test/CXX/module/basic/basic.link/p2.cppm create mode 100644 clang/test/CXX/module/basic/basic.link/p3.cppm create mode 100644 clang/test/CXX/module/basic/basic.search/module-import.cppm create mode 100644 clang/test/CXX/module/codegen-basics.cppm create mode 100644 clang/test/CXX/module/dcl.dcl/dcl.module/dcl.module.export/p1.cppm create mode 100644 clang/test/CXX/module/dcl.dcl/dcl.module/dcl.module.import/p1.cppm rename clang/test/CXX/{modules-ts/dcl.dcl/dcl.module/dcl.module.interface/p1.cpp => module/dcl.dcl/dcl.module/dcl.module.interface/p1.cppm} (53%) create mode 100644 clang/test/CXX/module/dcl.dcl/dcl.module/p1.cpp rename clang/test/CXX/{modules-ts => module}/dcl.dcl/dcl.module/p2.cpp (80%) rename clang/test/CXX/{modules-ts => module}/dcl.dcl/dcl.module/p5.cpp (51%) delete mode 100644 clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp delete mode 100644 clang/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp delete mode 100644 clang/test/CXX/modules-ts/basic/basic.def.odr/p6/global-vs-module.cpp delete mode 100644 clang/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-global.cpp delete mode 100644 clang/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-module.cpp delete mode 100644 clang/test/CXX/modules-ts/basic/basic.link/p2/module.cpp delete mode 100644 clang/test/CXX/modules-ts/basic/basic.link/p2/module.cppm delete mode 100644 clang/test/CXX/modules-ts/basic/basic.link/p2/other.cpp delete mode 100644 clang/test/CXX/modules-ts/basic/basic.link/p3.cppm delete mode 100644 clang/test/CXX/modules-ts/basic/basic.search/module-import.cpp delete mode 100644 clang/test/CXX/modules-ts/codegen-basics.cppm delete mode 100644 clang/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.export/p1.cpp delete mode 100644 clang/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.import/p1.cpp delete mode 100644 clang/test/CXX/modules-ts/dcl.dcl/dcl.module/p1.cpp delete mode 100644 clang/test/Driver/modules-ts.cpp delete mode 100644 clang/test/Lexer/modules-ts.cpp delete mode 100644 clang/test/Modules/anon-linkage.cpp create mode 100644 clang/test/Modules/anon-linkage.cppm rename clang/test/SemaCXX/{modules-ts.cppm => modules.cppm} (67%) diff --git a/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm b/clang/test/CXX/module/basic/basic.def.odr/p4.cppm similarity index 54% rename from clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm rename to clang/test/CXX/module/basic/basic.def.odr/p4.cppm index c25c32d..a07913c 100644 --- a/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm +++ b/clang/test/CXX/module/basic/basic.def.odr/p4.cppm @@ -1,5 +1,15 @@ -// RUN: %clang_cc1 -fmodules-ts %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s --implicit-check-not unused_inline --implicit-check-not unused_stastic_global_module +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: split-file %s %t +// +// RUN: %clang_cc1 -std=c++20 %t/Module.cppm -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %t/Module.cppm --implicit-check-not unused_inline --implicit-check-not unused_stastic_global_module +// +// RUN: %clang_cc1 -std=c++20 %t/Module.cppm -triple %itanium_abi_triple -emit-module-interface -o %t/Module.pcm +// RUN: %clang_cc1 -std=c++20 %t/module.cpp -triple %itanium_abi_triple -fmodule-file=%t/Module.pcm -emit-llvm -o - | FileCheck %t/module.cpp --implicit-check-not=unused --implicit-check-not=global_module +// +// RUN: %clang_cc1 -std=c++20 %t/user.cpp -triple %itanium_abi_triple -fmodule-file=%t/Module.pcm -emit-llvm -o - | FileCheck %t/user.cpp --implicit-check-not=unused --implicit-check-not=global_module +//--- Module.cppm // CHECK-DAG: @extern_var_global_module = external {{(dso_local )?}}global // CHECK-DAG: @inline_var_global_module = linkonce_odr {{(dso_local )?}}global // CHECK-DAG: @_ZL24static_var_global_module = internal global @@ -19,12 +29,14 @@ // can discard this global and its initializer (if any), and other TUs are not // permitted to run the initializer for this variable. // CHECK-DAG: @_ZW6Module25inline_var_module_linkage = linkonce_odr {{(dso_local )?}}global -// CHECK-DAG: @_ZW6Module25static_var_module_linkage = {{(dso_local )?}}global -// CHECK-DAG: @_ZW6Module24const_var_module_linkage = {{(dso_local )?}}constant +// CHECK-DAG: @_ZL25static_var_module_linkage = internal +// CHECK-DAG: @_ZL24const_var_module_linkage = internal // // CHECK-DAG: @_ZW6Module25unused_var_module_linkage = {{(dso_local )?}}global i32 4 -// CHECK-DAG: @_ZW6Module32unused_static_var_module_linkage = {{(dso_local )?}}global i32 5 -// CHECK-DAG: @_ZW6Module31unused_const_var_module_linkage = {{(dso_local )?}}constant i32 7 +// CHECK-NOT: @_ZW6Module32unused_static_var_module_linkage = +// CHECK-NOT: @_ZW6Module31unused_const_var_module_linkage = + +module; static void unused_static_global_module() {} static void used_static_global_module() {} @@ -73,12 +85,9 @@ export { } } -// FIXME: Ideally we wouldn't emit this as its name is not visible outside this -// TU, but this module interface might contain a template that can use this -// function so we conservatively emit it for now. -// CHECK: define {{(dso_local )?}}void {{.*}}@_ZW6Module28unused_static_module_linkagev +// CHECK-NOT: define {{(dso_local )?}}void {{.*}}@_ZW6Module28unused_static_module_linkagev static void unused_static_module_linkage() {} -// CHECK: define {{(dso_local )?}}void {{.*}}@_ZW6Module26used_static_module_linkagev + static void used_static_module_linkage() {} inline void unused_inline_module_linkage() {} @@ -90,6 +99,7 @@ static int static_var_module_linkage; const int const_var_module_linkage = 3; // CHECK: define {{(dso_local )?}}void {{.*}}@_ZW6Module24noninline_module_linkagev +// CHECK: define {{.*}}void {{.*}}@_ZL26used_static_module_linkagev void noninline_module_linkage() { used_static_module_linkage(); // CHECK: define linkonce_odr {{.*}}@_ZW6Module26used_inline_module_linkagev @@ -112,3 +122,62 @@ struct a { }; // CHECK: define {{(dso_local )?}}void @_ZW6Module1fNS_1a1bENS0_1cE( void f(a::b, a::c) {} + +//--- module.cpp + +// CHECK-DAG: @_ZW6Module19extern_var_exported = external {{(dso_local )?}}global +// CHECK-DAG: @_ZW6Module19inline_var_exported = linkonce_odr {{(dso_local )?}}global +// CHECK-DAG: @_ZW6Module18const_var_exported = available_externally {{(dso_local )?}}constant i32 3, +// +// CHECK-DAG: @_ZW6Module25extern_var_module_linkage = external {{(dso_local )?}}global +// CHECK-DAG: @_ZW6Module25inline_var_module_linkage = linkonce_odr {{(dso_local )?}}global +// CHECK-DAG: @_ZL25static_var_module_linkage = internal {{(dso_local )?}}global i32 0, +// CHECK-DAG: @_ZL24const_var_module_linkage = internal {{(dso_local )?}}constant i32 3, + +module Module; + +void use() { + // CHECK: define linkonce_odr {{.*}}@_ZW6Module20used_inline_exportedv + used_inline_exported(); + // CHECK: declare {{.*}}@_ZW6Module18noninline_exportedv + noninline_exported(); + + (void)&extern_var_exported; + (void)&inline_var_exported; + (void)&const_var_exported; + + // CHECK: define {{.*}}@_ZL26used_static_module_linkagev + used_static_module_linkage(); + + // CHECK: define linkonce_odr {{.*}}@_ZW6Module26used_inline_module_linkagev + used_inline_module_linkage(); + + // CHECK: declare {{.*}}@_ZW6Module24noninline_module_linkagev + noninline_module_linkage(); + + (void)&extern_var_module_linkage; + (void)&inline_var_module_linkage; + (void)&static_var_module_linkage; // FIXME: Should not be visible here. + (void)&const_var_module_linkage; +} + +//--- user.cpp + +// CHECK-DAG: @_ZW6Module19extern_var_exported = external {{(dso_local )?}}global +// CHECK-DAG: @_ZW6Module19inline_var_exported = linkonce_odr {{(dso_local )?}}global +// CHECK-DAG: @_ZW6Module18const_var_exported = available_externally {{(dso_local )?}}constant i32 3 + +import Module; + +void use() { + // CHECK: define linkonce_odr {{.*}}@_ZW6Module20used_inline_exportedv + used_inline_exported(); + // CHECK: declare {{.*}}@_ZW6Module18noninline_exportedv + noninline_exported(); + + (void)&extern_var_exported; + (void)&inline_var_exported; + (void)&const_var_exported; + + // Module-linkage declarations are not visible here. +} diff --git a/clang/test/CXX/module/basic/basic.def.odr/p6.cppm b/clang/test/CXX/module/basic/basic.def.odr/p6.cppm new file mode 100644 index 0000000..ae9a55a --- /dev/null +++ b/clang/test/CXX/module/basic/basic.def.odr/p6.cppm @@ -0,0 +1,124 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: split-file %s %t +// +// RUN: %clang_cc1 -std=c++20 -verify %t/global-vs-module.cppm +// RUN: %clang_cc1 -std=c++20 -verify %t/global-vs-module.cppm -DEXPORT +// RUN: %clang_cc1 -std=c++20 -verify %t/global-vs-module.cppm -DUSING +// +// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/global-vs-module.cppm -o %t/M.pcm -DNO_GLOBAL -DEXPORT +// RUN: %clang_cc1 -std=c++20 -verify %t/module-vs-global.cpp -fmodule-file=%t/M.pcm +// +// Some of the following tests intentionally have no -verify in their RUN +// lines; we are testing that those cases do not produce errors. +// +// RUN: %clang_cc1 -std=c++20 %t/module-vs-module.cpp -fmodule-file=%t/M.pcm -DMODULE_INTERFACE -verify +// RUN: %clang_cc1 -std=c++20 %t/module-vs-module.cpp -fmodule-file=%t/M.pcm -DMODULE_INTERFACE -DNO_IMPORT +// +// RUN: %clang_cc1 -std=c++20 %t/module-vs-module.cpp -fmodule-file=%t/M.pcm -emit-module-interface -o %t/N.pcm -DMODULE_INTERFACE -DNO_ERRORS +// RUN: %clang_cc1 -std=c++20 %t/module-vs-module.cpp -fmodule-file=%t/N.pcm -verify +// FIXME: Once we start importing "import" declarations properly, this should +// be rejected (-verify should be added to the following line). +// RUN: %clang_cc1 -std=c++20 %t/module-vs-module.cpp -fmodule-file=%t/N.pcm -DNO_IMPORT +// +// RUN: %clang_cc1 -std=c++20 %t/module-vs-module.cpp -fmodule-file=%t/M.pcm -emit-module-interface -o %t/N-no-M.pcm -DMODULE_INTERFACE -DNO_ERRORS -DNO_IMPORT +// RUN: %clang_cc1 -std=c++20 %t/module-vs-module.cpp -fmodule-file=%t/N-no-M.pcm -verify +// RUN: %clang_cc1 -std=c++20 %t/module-vs-module.cpp -fmodule-file=%t/N-no-M.pcm -DNO_IMPORT + +//--- global-vs-module.cppm +#ifndef NO_GLOBAL +module; +extern int var; // expected-note {{previous declaration is here}} +int func(); // expected-note {{previous declaration is here}} +struct str; // expected-note {{previous declaration is here}} +using type = int; + +template extern int var_tpl; // expected-note {{previous declaration is here}} +template int func_tpl(); // expected-note {{previous declaration is here}} +template struct str_tpl; // expected-note {{previous declaration is here}} +template using type_tpl = int; // expected-note {{previous declaration is here}} + +typedef int type; +namespace ns { using ::func; } +namespace ns_alias = ns; +#endif + +export module M; + +#ifdef USING +using ::var; +using ::func; +using ::str; +using ::type; +using ::var_tpl; +using ::func_tpl; +using ::str_tpl; +using ::type_tpl; +#endif + +#ifdef EXPORT +export { +#endif + +extern int var; // expected-error {{declaration of 'var' in module M follows declaration in the global module}} +int func(); // expected-error {{declaration of 'func' in module M follows declaration in the global module}} +struct str; // expected-error {{declaration of 'str' in module M follows declaration in the global module}} +using type = int; + +template extern int var_tpl; // expected-error {{declaration of 'var_tpl' in module M follows declaration in the global module}} +template int func_tpl(); // expected-error {{declaration of 'func_tpl' in module M follows declaration in the global module}} +template struct str_tpl; // expected-error {{declaration of 'str_tpl' in module M follows declaration in the global module}} +template using type_tpl = int; // expected-error {{declaration of 'type_tpl' in module M follows declaration in the global module}} + +typedef int type; +namespace ns { using ::func; } +namespace ns_alias = ns; + +#ifdef EXPORT +} +#endif + +//--- module-vs-global.cpp +import M; + +extern int var; // expected-error {{declaration of 'var' in the global module follows declaration in module M}} expected-note@global-vs-module.cppm:35 {{previous}} +int func(); // expected-error {{declaration of 'func' in the global module follows declaration in module M}} expected-note@global-vs-module.cppm:36 {{previous}} +struct str; // expected-error {{declaration of 'str' in the global module follows declaration in module M}} expected-note@global-vs-module.cppm:37 {{previous}} +using type = int; + +template extern int var_tpl; // expected-error {{declaration of 'var_tpl' in the global module follows declaration in module M}} expected-note@global-vs-module.cppm:40 {{previous}} +template int func_tpl(); // expected-error {{declaration of 'func_tpl' in the global module follows declaration in module M}} expected-note@global-vs-module.cppm:41 {{previous}} +template struct str_tpl; // expected-error {{declaration of 'str_tpl' in the global module follows declaration in module M}} expected-note@global-vs-module.cppm:42 {{previous}} +template using type_tpl = int; // expected-error {{declaration of 'type_tpl' in the global module follows declaration in module M}} expected-note@global-vs-module.cppm:43 {{previous}} + +typedef int type; +namespace ns { using ::func; } +namespace ns_alias = ns; + +//--- module-vs-module.cpp +#ifdef MODULE_INTERFACE +export module N; +#else +module N; +#endif + +#ifndef NO_IMPORT +import M; +#endif + +#ifndef NO_ERRORS +extern int var; // expected-error {{declaration of 'var' in module N follows declaration in module M}} expected-note@global-vs-module.cppm:35 {{previous}} +int func(); // expected-error {{declaration of 'func' in module N follows declaration in module M}} expected-note@global-vs-module.cppm:36 {{previous}} +struct str; // expected-error {{declaration of 'str' in module N follows declaration in module M}} expected-note@global-vs-module.cppm:37 {{previous}} +using type = int; + +template extern int var_tpl; // expected-error {{declaration of 'var_tpl' in module N follows declaration in module M}} expected-note@global-vs-module.cppm:40 {{previous}} +template int func_tpl(); // expected-error {{declaration of 'func_tpl' in module N follows declaration in module M}} expected-note@global-vs-module.cppm:41 {{previous}} +template struct str_tpl; // expected-error {{declaration of 'str_tpl' in module N follows declaration in module M}} expected-note@global-vs-module.cppm:42 {{previous}} +template using type_tpl = int; // expected-error {{declaration of 'type_tpl' in module N follows declaration in module M}} expected-note@global-vs-module.cppm:43 {{previous}} + +typedef int type; +namespace ns { using ::func; } +namespace ns_alias = ns; +#endif + diff --git a/clang/test/CXX/modules-ts/basic/basic.link/module-declaration.cpp b/clang/test/CXX/module/basic/basic.link/module-declaration.cpp similarity index 53% rename from clang/test/CXX/modules-ts/basic/basic.link/module-declaration.cpp rename to clang/test/CXX/module/basic/basic.link/module-declaration.cpp index 6cdf04a..81b6a98 100644 --- a/clang/test/CXX/modules-ts/basic/basic.link/module-declaration.cpp +++ b/clang/test/CXX/module/basic/basic.link/module-declaration.cpp @@ -1,40 +1,49 @@ // Tests for module-declaration syntax. // // RUN: rm -rf %t -// RUN: mkdir -p %t -// RUN: echo 'export module x; int a, b;' > %t/x.cppm -// RUN: echo 'export module x.y; int c;' > %t/x.y.cppm +// RUN: mkdir %t +// RUN: split-file %s %t // -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %t/x.cppm -o %t/x.pcm -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface -fmodule-file=%t/x.pcm %t/x.y.cppm -o %t/x.y.pcm +// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/x.cppm -o %t/x.pcm +// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fmodule-file=%t/x.pcm %t/x.y.cppm -o %t/x.y.pcm // // Module implementation for unknown and known module. (The former is ill-formed.) -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ +// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=%t/x.y.pcm -verify -x c++ %t/M.cpp \ // RUN: -DTEST=1 -DEXPORT= -DMODULE_NAME=z -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ +// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=%t/x.y.pcm -verify -x c++ %t/M.cpp \ // RUN: -DTEST=2 -DEXPORT= -DMODULE_NAME=x // // Module interface for unknown and known module. (The latter is ill-formed due to // redefinition.) -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ +// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=%t/x.y.pcm -verify %t/M.cpp \ // RUN: -DTEST=3 -DEXPORT=export -DMODULE_NAME=z -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ +// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=%t/x.y.pcm -verify %t/M.cpp \ // RUN: -DTEST=4 -DEXPORT=export -DMODULE_NAME=x // // Miscellaneous syntax. -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ +// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=%t/x.y.pcm -verify %t/M.cpp \ // RUN: -DTEST=7 -DEXPORT=export -DMODULE_NAME='z elderberry' -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ +// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=%t/x.y.pcm -verify %t/M.cpp \ // RUN: -DTEST=8 -DEXPORT=export -DMODULE_NAME='z [[]]' -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ +// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=%t/x.y.pcm -verify %t/M.cpp \ // RUN: -DTEST=9 -DEXPORT=export -DMODULE_NAME='z [[fancy]]' -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ +// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=%t/x.y.pcm -verify %t/M.cpp \ // RUN: -DTEST=10 -DEXPORT=export -DMODULE_NAME='z [[maybe_unused]]' +//--- x.cppm +export module x; +int a, b; + +//--- x.y.cppm +export module x.y; +int c; + +//--- M.cpp + EXPORT module MODULE_NAME; #if TEST == 4 // expected-error@-2 {{redefinition of module 'x'}} -// expected-note-re@module-declaration.cpp:* {{loaded from '{{.*[/\\]}}x.pcm'}} +// expected-note-re@* {{loaded from '{{.*[/\\]}}x.pcm'}} #elif TEST == 7 // expected-error@-5 {{expected ';'}} expected-error@-5 {{a type specifier is required}} #elif TEST == 9 diff --git a/clang/test/CXX/module/basic/basic.link/p2.cppm b/clang/test/CXX/module/basic/basic.link/p2.cppm new file mode 100644 index 0000000..e82a00b --- /dev/null +++ b/clang/test/CXX/module/basic/basic.link/p2.cppm @@ -0,0 +1,73 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: split-file %s %t + +// RUN: %clang_cc1 -std=c++20 %t/M.cppm -verify +// RUN: %clang_cc1 -std=c++20 %t/M.cppm -emit-module-interface -o %t/M.pcm +// RUN: %clang_cc1 -std=c++20 -fmodule-file=%t/M.pcm %t/M.cpp -verify +// +// RUN: %clang_cc1 -std=c++20 -fmodule-file=%t/M.pcm %t/user.cpp -verify + +//--- M.cppm +// expected-no-diagnostics +export module M; + +export int external_linkage_var; +int module_linkage_var; +static int internal_linkage_var; + +export void external_linkage_fn() {} +void module_linkage_fn() {} +static void internal_linkage_fn() {} + +export struct external_linkage_class {}; +struct module_linkage_class {}; +namespace { +struct internal_linkage_class {}; +} // namespace + +void use() { + external_linkage_fn(); + module_linkage_fn(); + internal_linkage_fn(); + (void)external_linkage_class{}; + (void)module_linkage_class{}; + (void)internal_linkage_class{}; + (void)external_linkage_var; + (void)module_linkage_var; + (void)internal_linkage_var; +} + +//--- M.cpp +// expected-no-diagnostics +module M; + +// FIXME: Use of internal linkage entities should be rejected. +void use_from_module_impl() { + external_linkage_fn(); + module_linkage_fn(); + internal_linkage_fn(); + (void)external_linkage_class{}; + (void)module_linkage_class{}; + (void)internal_linkage_class{}; + (void)external_linkage_var; + (void)module_linkage_var; + (void)internal_linkage_var; +} + +//--- user.cpp +import M; + +void use_from_module_impl() { + external_linkage_fn(); + module_linkage_fn(); // expected-error {{declaration of 'module_linkage_fn' must be imported}} + internal_linkage_fn(); // expected-error {{declaration of 'internal_linkage_fn' must be imported}} + (void)external_linkage_class{}; + (void)module_linkage_class{}; // expected-error {{undeclared identifier}} expected-error 0+{{}} + (void)internal_linkage_class{}; // expected-error {{undeclared identifier}} expected-error 0+{{}} + // expected-note@M.cppm:9 {{declaration here is not visible}} + // expected-note@M.cppm:10 {{declaration here is not visible}} + (void)external_linkage_var; + (void)module_linkage_var; // expected-error {{undeclared identifier}} + (void)internal_linkage_var; // expected-error {{undeclared identifier}} +} diff --git a/clang/test/CXX/module/basic/basic.link/p3.cppm b/clang/test/CXX/module/basic/basic.link/p3.cppm new file mode 100644 index 0000000..60505d8 --- /dev/null +++ b/clang/test/CXX/module/basic/basic.link/p3.cppm @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -std=c++20 -triple x86_64-linux %s -emit-module-interface -o %t +// RUN: %clang_cc1 -std=c++20 -triple x86_64-linux -x pcm %t -emit-llvm -o - | FileCheck %s + +export module M; + +// CHECK-NOT: @_ZW1M1a ={{.*}} +const int a = 1; +// CHECK: @_ZW1M1b ={{.*}} constant i32 2 +export const int b = 2; + +export int f() { return a + b; } diff --git a/clang/test/CXX/module/basic/basic.search/module-import.cppm b/clang/test/CXX/module/basic/basic.search/module-import.cppm new file mode 100644 index 0000000..18b7eb4 --- /dev/null +++ b/clang/test/CXX/module/basic/basic.search/module-import.cppm @@ -0,0 +1,52 @@ +// Tests for imported module search. +// +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: split-file %s %t +// +// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/x.cppm -o %t/x.pcm +// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fmodule-file=%t/x.pcm %t/y.cppm -o %t/y.pcm +// +// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=%t/x.pcm -verify %t/use.cpp \ +// RUN: -DMODULE_NAME=x +// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=%t/y.pcm -verify %t/use.cpp \ +// RUN: -DMODULE_NAME=y +// +// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x=%t/x.pcm -verify %t/use.cpp \ +// RUN: -DMODULE_NAME=x +// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=y=%t/y.pcm -verify %t/use.cpp \ +// RUN: -DMODULE_NAME=y +// +// RUN: mv %t/x.pcm %t/a.pcm +// +// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=x=%t/a.pcm -verify %t/use.cpp \ +// RUN: -DMODULE_NAME=x +// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=%t/y.pcm -fmodule-file=x=%t/a.pcm -verify %t/use.cpp \ +// RUN: -DMODULE_NAME=y +// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=y=%t/y.pcm -fmodule-file=x=%t/a.pcm -verify %t/use.cpp \ +// RUN: -DMODULE_NAME=y +// +// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fmodule-file=y=%t/y.pcm -fmodule-file=x=%t/a.pcm %t/z.cppm -o %t/z.pcm +// +// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=z=%t/z.pcm -fmodule-file=y=%t/y.pcm -fmodule-file=x=%t/a.pcm -verify %t/use.cpp \ +// RUN: -DMODULE_NAME=z +// + +//--- x.cppm +export module x; +int a, b; + +//--- y.cppm +export module y; +import x; +int c; + +//--- z.cppm +export module z; +import y; +int d; + +//--- use.cpp +import MODULE_NAME; + +// expected-no-diagnostics diff --git a/clang/test/CXX/module/codegen-basics.cppm b/clang/test/CXX/module/codegen-basics.cppm new file mode 100644 index 0000000..674252b --- /dev/null +++ b/clang/test/CXX/module/codegen-basics.cppm @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -std=c++20 -triple=x86_64-linux-gnu -fmodules-codegen -emit-module-interface %s -o %t.pcm +// RUN: %clang_cc1 -std=c++20 -triple=x86_64-linux-gnu %t.pcm -emit-llvm -o - | FileCheck %s + +export module FooBar; + +export { + // CHECK-DAG: define{{.*}} i32 @_ZW6FooBar1fv( + int f() { return 0; } +} + +// CHECK-DAG: define weak_odr void @_ZW6FooBar2f2v( +inline void f2() {} + +// CHECK-DAG: define{{.*}} void @_ZL2f3v( +static void f3() {} +export void use_f3() { f3(); } diff --git a/clang/test/CXX/module/dcl.dcl/dcl.module/dcl.module.export/p1.cppm b/clang/test/CXX/module/dcl.dcl/dcl.module/dcl.module.export/p1.cppm new file mode 100644 index 0000000..3ad371b --- /dev/null +++ b/clang/test/CXX/module/dcl.dcl/dcl.module/dcl.module.export/p1.cppm @@ -0,0 +1,47 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: split-file %s %t +// +// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/a.cppm -o %t/a.pcm +// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/b.cppm -o %t/b.pcm +// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/c.cppm -o %t/c.pcm +// +// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -emit-module-interface %t/aggregate.internal.cppm -o %t/aggregate.internal.pcm +// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -emit-module-interface %t/aggregate.cppm -o %t/aggregate.pcm +// +// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/use.cpp -verify -DTEST + + +//--- a.cppm +export module a; +export class A{}; + +//--- b.cppm +export module b; +export class B{}; + +//--- c.cppm +export module c; +export class C{}; + +//--- aggregate.internal.cppm +export module aggregate.internal; +export import a; +export import b; +export import c; + +//--- aggregate.cppm +// Export the above aggregate module. +// This is done to ensure that re-exports are transitive. +export module aggregate; +export import aggregate.internal; + + +//--- use.cpp +// expected-no-diagnostics +// For the actual test, just try using the classes from the exported modules +// and hope that they're accessible. +import aggregate; +A a; +B b; +C c; diff --git a/clang/test/CXX/module/dcl.dcl/dcl.module/dcl.module.import/p1.cppm b/clang/test/CXX/module/dcl.dcl/dcl.module/dcl.module.import/p1.cppm new file mode 100644 index 0000000..64133ac --- /dev/null +++ b/clang/test/CXX/module/dcl.dcl/dcl.module/dcl.module.import/p1.cppm @@ -0,0 +1,57 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: split-file %s %t +// +// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/x.cppm -o %t/x.pcm +// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fmodule-file=%t/x.pcm %t/x.y.cppm -o %t/x.y.pcm +// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/a.b.cppm -o %t/a.b.pcm +// +// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=%t/x.y.pcm -fmodule-file=%t/a.b.pcm -verify %t/test.cpp \ +// RUN: -DMODULE_NAME=z -DINTERFACE +// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=%t/x.y.pcm -fmodule-file=%t/a.b.pcm -verify %t/test.cpp \ +// RUN: -DMODULE_NAME=a.b +// RUN: %clang_cc1 -std=c++20 -I%t -fmodule-file=%t/x.y.pcm -fmodule-file=%t/a.b.pcm -verify %t/test.x.cpp + +//--- x.cppm +export module x; +export int a, b; + +//--- x.y.cppm +export module x.y; +export int c; + +//--- a.b.cppm +export module a.b; +export int d; + +//--- test.x.cpp +module x; +int use_1 = a; // ok + +int use_2 = b; // ok + +// There is no relation between module x and module x.y. +int use_3 = c; // expected-error {{declaration of 'c' must be imported from module 'x.y'}} + // expected-note@x.y.cppm:2 {{not visible}} + +//--- test.cpp +#ifdef INTERFACE +export module MODULE_NAME; +#else +module MODULE_NAME; +#endif + +import x; + +import x [[]]; +import x [[foo]]; // expected-warning {{unknown attribute 'foo' ignored}} +import x [[noreturn]]; // expected-error {{'noreturn' attribute cannot be applied to a module import}} +import x [[blarg::noreturn]]; // expected-warning {{unknown attribute 'noreturn' ignored}} + +import x.y; +import x.; // expected-error {{expected a module name after 'import'}} +import .x; // expected-error {{expected a module name after 'import'}} + +import blarg; // expected-error {{module 'blarg' not found}} + +int use_4 = c; // ok diff --git a/clang/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.interface/p1.cpp b/clang/test/CXX/module/dcl.dcl/dcl.module/dcl.module.interface/p1.cppm similarity index 53% rename from clang/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.interface/p1.cpp rename to clang/test/CXX/module/dcl.dcl/dcl.module/dcl.module.interface/p1.cppm index 52f45f5..dda58479 100644 --- a/clang/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.interface/p1.cpp +++ b/clang/test/CXX/module/dcl.dcl/dcl.module/dcl.module.interface/p1.cppm @@ -1,10 +1,10 @@ -// RUN: %clang_cc1 -fmodules-ts %s -verify -o /dev/null -// RUN: %clang_cc1 -fmodules-ts %s -DINTERFACE -verify -emit-module-interface -o %t -// RUN: %clang_cc1 -fmodules-ts %s -DIMPLEMENTATION -verify -fmodule-file=%t -o /dev/null +// RUN: %clang_cc1 -std=c++20 %s -verify -o /dev/null +// RUN: %clang_cc1 -std=c++20 %s -DINTERFACE -verify -emit-module-interface -o %t +// RUN: %clang_cc1 -std=c++20 %s -DIMPLEMENTATION -verify -fmodule-file=%t -o /dev/null // -// RUN: %clang_cc1 -fmodules-ts %s -DBUILT_AS_INTERFACE -emit-module-interface -verify -o /dev/null -// RUN: %clang_cc1 -fmodules-ts %s -DINTERFACE -DBUILT_AS_INTERFACE -emit-module-interface -verify -o /dev/null -// RUN: %clang_cc1 -fmodules-ts %s -DIMPLEMENTATION -DBUILT_AS_INTERFACE -emit-module-interface -verify -o /dev/null +// RUN: %clang_cc1 -std=c++20 %s -DBUILT_AS_INTERFACE -emit-module-interface -verify -o /dev/null +// RUN: %clang_cc1 -std=c++20 %s -DINTERFACE -DBUILT_AS_INTERFACE -emit-module-interface -verify -o /dev/null +// RUN: %clang_cc1 -std=c++20 %s -DIMPLEMENTATION -DBUILT_AS_INTERFACE -emit-module-interface -verify -o /dev/null #if INTERFACE // expected-no-diagnostics diff --git a/clang/test/CXX/module/dcl.dcl/dcl.module/p1.cpp b/clang/test/CXX/module/dcl.dcl/dcl.module/p1.cpp new file mode 100644 index 0000000..52da32c --- /dev/null +++ b/clang/test/CXX/module/dcl.dcl/dcl.module/p1.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -std=c++20 -verify %s -DFOO=export -DBAR=export +// RUN: %clang_cc1 -std=c++20 -verify %s -DFOO=export -DBAR= +// RUN: %clang_cc1 -std=c++20 %s -DFOO=export -emit-module-interface -o %t +// RUN: %clang_cc1 -std=c++20 %s -fmodule-file=%t -DFOO= +// RUN: %clang_cc1 -std=c++20 %s -fmodule-file=%t -DBAR=export +// RUN: %clang_cc1 -std=c++20 -verify %s -fmodule-file=%t -DFOO= -DBAR=export + +#ifdef FOO +FOO module foo; // expected-note {{previous module declaration is here}} +#endif + +#ifdef BAR +BAR module bar; // expected-error {{translation unit contains multiple module declarations}} +#endif diff --git a/clang/test/CXX/modules-ts/dcl.dcl/dcl.module/p2.cpp b/clang/test/CXX/module/dcl.dcl/dcl.module/p2.cpp similarity index 80% rename from clang/test/CXX/modules-ts/dcl.dcl/dcl.module/p2.cpp rename to clang/test/CXX/module/dcl.dcl/dcl.module/p2.cpp index 53ab19e..32419a1 100644 --- a/clang/test/CXX/modules-ts/dcl.dcl/dcl.module/p2.cpp +++ b/clang/test/CXX/module/dcl.dcl/dcl.module/p2.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fmodules-ts -verify %s +// RUN: %clang_cc1 -std=c++20 -verify %s // A named module shall contain exactly one module interface unit. module M; // expected-error {{module 'M' not found}} diff --git a/clang/test/CXX/modules-ts/dcl.dcl/dcl.module/p5.cpp b/clang/test/CXX/module/dcl.dcl/dcl.module/p5.cpp similarity index 51% rename from clang/test/CXX/modules-ts/dcl.dcl/dcl.module/p5.cpp rename to clang/test/CXX/module/dcl.dcl/dcl.module/p5.cpp index 734b891..f594e76 100644 --- a/clang/test/CXX/modules-ts/dcl.dcl/dcl.module/p5.cpp +++ b/clang/test/CXX/module/dcl.dcl/dcl.module/p5.cpp @@ -1,11 +1,15 @@ -// RUN: rm -f %t -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -o %t -DINTERFACE -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -fmodule-file=%t %s -verify -DIMPLEMENTATION -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -fmodule-file=%t %s -verify -DEARLY_IMPLEMENTATION -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -fmodule-file=%t %s -verify -DUSER +// RUN: rm -rf %t +// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -o %t -DINTERFACE +// RUN: %clang_cc1 -std=c++20 -fmodule-file=%t %s -verify -DIMPLEMENTATION +// RUN: %clang_cc1 -std=c++20 -fmodule-file=%t %s -verify -DEARLY_IMPLEMENTATION +// RUN: %clang_cc1 -std=c++20 -fmodule-file=%t %s -verify -DUSER // expected-no-diagnostics +#if defined(INTERFACE) || defined(EARLY_IMPLEMENTATION) || defined(IMPLEMENTATION) +module; +#endif + #ifdef USER import Foo; #endif diff --git a/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp b/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp deleted file mode 100644 index 0e300a1..0000000 --- a/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// RUN: %clang_cc1 -fmodules-ts %S/module.cppm -triple %itanium_abi_triple -emit-module-interface -o %t -// RUN: %clang_cc1 -fmodules-ts %s -triple %itanium_abi_triple -fmodule-file=%t -emit-llvm -o - | FileCheck %s --implicit-check-not=unused --implicit-check-not=global_module - -// CHECK-DAG: @_ZW6Module19extern_var_exported = external {{(dso_local )?}}global -// CHECK-DAG: @_ZW6Module19inline_var_exported = linkonce_odr {{(dso_local )?}}global -// CHECK-DAG: @_ZW6Module18const_var_exported = available_externally {{(dso_local )?}}constant i32 3, -// -// CHECK-DAG: @_ZW6Module25extern_var_module_linkage = external {{(dso_local )?}}global -// CHECK-DAG: @_ZW6Module25inline_var_module_linkage = linkonce_odr {{(dso_local )?}}global -// CHECK-DAG: @_ZW6Module25static_var_module_linkage = available_externally {{(dso_local )?}}global i32 0, -// CHECK-DAG: @_ZW6Module24const_var_module_linkage = available_externally {{(dso_local )?}}constant i32 3, - -module Module; - -void use() { - // CHECK: define linkonce_odr {{.*}}@_ZW6Module20used_inline_exportedv - used_inline_exported(); - // CHECK: declare {{.*}}@_ZW6Module18noninline_exportedv - noninline_exported(); - - (void)&extern_var_exported; - (void)&inline_var_exported; - (void)&const_var_exported; - - // FIXME: This symbol should not be visible here. - // CHECK: declare {{.*}}@_ZW6Module26used_static_module_linkagev - used_static_module_linkage(); - - // CHECK: define linkonce_odr {{.*}}@_ZW6Module26used_inline_module_linkagev - used_inline_module_linkage(); - - // CHECK: declare {{.*}}@_ZW6Module24noninline_module_linkagev - noninline_module_linkage(); - - (void)&extern_var_module_linkage; - (void)&inline_var_module_linkage; - (void)&static_var_module_linkage; // FIXME: Should not be visible here. - (void)&const_var_module_linkage; -} diff --git a/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp b/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp deleted file mode 100644 index 6c795b9..0000000 --- a/clang/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: %clang_cc1 -fmodules-ts %S/module.cppm -triple %itanium_abi_triple -emit-module-interface -o %t -// RUN: %clang_cc1 -fmodules-ts %s -triple %itanium_abi_triple -fmodule-file=%t -emit-llvm -o - | FileCheck %s --implicit-check-not=unused --implicit-check-not=global_module - -// CHECK-DAG: @_ZW6Module19extern_var_exported = external {{(dso_local )?}}global -// CHECK-DAG: @_ZW6Module19inline_var_exported = linkonce_odr {{(dso_local )?}}global -// CHECK-DAG: @_ZW6Module18const_var_exported = available_externally {{(dso_local )?}}constant i32 3 - -import Module; - -void use() { - // CHECK: define linkonce_odr {{.*}}@_ZW6Module20used_inline_exportedv - used_inline_exported(); - // CHECK: declare {{.*}}@_ZW6Module18noninline_exportedv - noninline_exported(); - - (void)&extern_var_exported; - (void)&inline_var_exported; - (void)&const_var_exported; - - // Module-linkage declarations are not visible here. -} diff --git a/clang/test/CXX/modules-ts/basic/basic.def.odr/p6/global-vs-module.cpp b/clang/test/CXX/modules-ts/basic/basic.def.odr/p6/global-vs-module.cpp deleted file mode 100644 index a16374a..0000000 --- a/clang/test/CXX/modules-ts/basic/basic.def.odr/p6/global-vs-module.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// RUN: %clang_cc1 -fmodules-ts -verify -std=c++17 %s -// RUN: %clang_cc1 -fmodules-ts -verify -std=c++17 %s -DEXPORT -// RUN: %clang_cc1 -fmodules-ts -verify -std=c++17 %s -DUSING - -#ifndef NO_GLOBAL -extern int var; // expected-note {{previous declaration is here}} -int func(); // expected-note {{previous declaration is here}} -struct str; // expected-note {{previous declaration is here}} -using type = int; - -template extern int var_tpl; // expected-note {{previous declaration is here}} -template int func_tpl(); // expected-note {{previous declaration is here}} -template struct str_tpl; // expected-note {{previous declaration is here}} -template using type_tpl = int; // expected-note {{previous declaration is here}} - -typedef int type; -namespace ns { using ::func; } -namespace ns_alias = ns; -#endif - -export module M; - -#ifdef USING -using ::var; -using ::func; -using ::str; -using ::type; -using ::var_tpl; -using ::func_tpl; -using ::str_tpl; -using ::type_tpl; -#endif - -#ifdef EXPORT -export { -#endif - -extern int var; // expected-error {{declaration of 'var' in module M follows declaration in the global module}} -int func(); // expected-error {{declaration of 'func' in module M follows declaration in the global module}} -struct str; // expected-error {{declaration of 'str' in module M follows declaration in the global module}} -using type = int; - -template extern int var_tpl; // expected-error {{declaration of 'var_tpl' in module M follows declaration in the global module}} -template int func_tpl(); // expected-error {{declaration of 'func_tpl' in module M follows declaration in the global module}} -template struct str_tpl; // expected-error {{declaration of 'str_tpl' in module M follows declaration in the global module}} -template using type_tpl = int; // expected-error {{declaration of 'type_tpl' in module M follows declaration in the global module}} - -typedef int type; -namespace ns { using ::func; } -namespace ns_alias = ns; - -#ifdef EXPORT -} -#endif diff --git a/clang/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-global.cpp b/clang/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-global.cpp deleted file mode 100644 index 50c153a..0000000 --- a/clang/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-global.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fmodules-ts -emit-module-interface -std=c++17 %S/global-vs-module.cpp -o %t -DNO_GLOBAL -DEXPORT -// RUN: %clang_cc1 -fmodules-ts -verify -std=c++17 %s -fmodule-file=%t - -import M; - -extern int var; // expected-error {{declaration of 'var' in the global module follows declaration in module M}} expected-note@global-vs-module.cpp:38 {{previous}} -int func(); // expected-error {{declaration of 'func' in the global module follows declaration in module M}} expected-note@global-vs-module.cpp:39 {{previous}} -struct str; // expected-error {{declaration of 'str' in the global module follows declaration in module M}} expected-note@global-vs-module.cpp:40 {{previous}} -using type = int; - -template extern int var_tpl; // expected-error {{declaration of 'var_tpl' in the global module follows declaration in module M}} expected-note@global-vs-module.cpp:43 {{previous}} -template int func_tpl(); // expected-error {{declaration of 'func_tpl' in the global module follows declaration in module M}} expected-note@global-vs-module.cpp:44 {{previous}} -template struct str_tpl; // expected-error {{declaration of 'str_tpl' in the global module follows declaration in module M}} expected-note@global-vs-module.cpp:45 {{previous}} -template using type_tpl = int; // expected-error {{declaration of 'type_tpl' in the global module follows declaration in module M}} expected-note@global-vs-module.cpp:46 {{previous}} - -typedef int type; -namespace ns { using ::func; } -namespace ns_alias = ns; diff --git a/clang/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-module.cpp b/clang/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-module.cpp deleted file mode 100644 index 4c5cb29..0000000 --- a/clang/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-module.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// RUN: rm -rf %t -// RUN: mkdir %t -// -// Some of the following tests intentionally have no -verify in their RUN -// lines; we are testing that those cases do not produce errors. -// -// RUN: %clang_cc1 -fmodules-ts -std=c++17 %S/global-vs-module.cpp -emit-module-interface -o %t/M.pcm -DNO_GLOBAL -DEXPORT -// RUN: %clang_cc1 -fmodules-ts -std=c++17 %s -fmodule-file=%t/M.pcm -DMODULE_INTERFACE -verify -// RUN: %clang_cc1 -fmodules-ts -std=c++17 %s -fmodule-file=%t/M.pcm -DMODULE_INTERFACE -DNO_IMPORT -// -// RUN: %clang_cc1 -fmodules-ts -std=c++17 %s -fmodule-file=%t/M.pcm -emit-module-interface -o %t/N.pcm -DMODULE_INTERFACE -DNO_ERRORS -// RUN: %clang_cc1 -fmodules-ts -std=c++17 %s -fmodule-file=%t/N.pcm -verify -// FIXME: Once we start importing "import" declarations properly, this should -// be rejected (-verify should be added to the following line). -// RUN: %clang_cc1 -fmodules-ts -std=c++17 %s -fmodule-file=%t/N.pcm -DNO_IMPORT -// -// RUN: %clang_cc1 -fmodules-ts -std=c++17 %s -fmodule-file=%t/M.pcm -emit-module-interface -o %t/N-no-M.pcm -DMODULE_INTERFACE -DNO_ERRORS -DNO_IMPORT -// RUN: %clang_cc1 -fmodules-ts -std=c++17 %s -fmodule-file=%t/N-no-M.pcm -verify -// RUN: %clang_cc1 -fmodules-ts -std=c++17 %s -fmodule-file=%t/N-no-M.pcm -DNO_IMPORT - -#ifdef MODULE_INTERFACE -export -#endif -module N; - -#ifndef NO_IMPORT -import M; -#endif - -#ifndef NO_ERRORS -extern int var; // expected-error {{declaration of 'var' in module N follows declaration in module M}} expected-note@global-vs-module.cpp:38 {{previous}} -int func(); // expected-error {{declaration of 'func' in module N follows declaration in module M}} expected-note@global-vs-module.cpp:39 {{previous}} -struct str; // expected-error {{declaration of 'str' in module N follows declaration in module M}} expected-note@global-vs-module.cpp:40 {{previous}} -using type = int; - -template extern int var_tpl; // expected-error {{declaration of 'var_tpl' in module N follows declaration in module M}} expected-note@global-vs-module.cpp:43 {{previous}} -template int func_tpl(); // expected-error {{declaration of 'func_tpl' in module N follows declaration in module M}} expected-note@global-vs-module.cpp:44 {{previous}} -template struct str_tpl; // expected-error {{declaration of 'str_tpl' in module N follows declaration in module M}} expected-note@global-vs-module.cpp:45 {{previous}} -template using type_tpl = int; // expected-error {{declaration of 'type_tpl' in module N follows declaration in module M}} expected-note@global-vs-module.cpp:46 {{previous}} - -typedef int type; -namespace ns { using ::func; } -namespace ns_alias = ns; -#endif diff --git a/clang/test/CXX/modules-ts/basic/basic.link/p2/module.cpp b/clang/test/CXX/modules-ts/basic/basic.link/p2/module.cpp deleted file mode 100644 index 3fc6044..0000000 --- a/clang/test/CXX/modules-ts/basic/basic.link/p2/module.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -fmodules-ts %S/module.cppm -emit-module-interface -o %t -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -fmodule-file=%t %s -verify -// expected-no-diagnostics -module M; - -// FIXME: Use of internal linkage entities should be rejected. -void use_from_module_impl() { - external_linkage_fn(); - module_linkage_fn(); - internal_linkage_fn(); - (void)external_linkage_class{}; - (void)module_linkage_class{}; - (void)internal_linkage_class{}; - (void)external_linkage_var; - (void)module_linkage_var; - (void)internal_linkage_var; -} diff --git a/clang/test/CXX/modules-ts/basic/basic.link/p2/module.cppm b/clang/test/CXX/modules-ts/basic/basic.link/p2/module.cppm deleted file mode 100644 index 1105243..0000000 --- a/clang/test/CXX/modules-ts/basic/basic.link/p2/module.cppm +++ /dev/null @@ -1,29 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -fmodules-ts %s -verify -// expected-no-diagnostics -export module M; - -export int external_linkage_var; -int module_linkage_var; -static int internal_linkage_var; - -export void external_linkage_fn() {} -void module_linkage_fn() {} -static void internal_linkage_fn() {} - -export struct external_linkage_class {}; -struct module_linkage_class {}; -namespace { -struct internal_linkage_class {}; -} // namespace - -void use() { - external_linkage_fn(); - module_linkage_fn(); - internal_linkage_fn(); - (void)external_linkage_class{}; - (void)module_linkage_class{}; - (void)internal_linkage_class{}; - (void)external_linkage_var; - (void)module_linkage_var; - (void)internal_linkage_var; -} diff --git a/clang/test/CXX/modules-ts/basic/basic.link/p2/other.cpp b/clang/test/CXX/modules-ts/basic/basic.link/p2/other.cpp deleted file mode 100644 index efac3f8..0000000 --- a/clang/test/CXX/modules-ts/basic/basic.link/p2/other.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -fmodules-ts %S/module.cppm -emit-module-interface -o %t -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -fmodule-file=%t %s -verify -import M; - -void use_from_module_impl() { - external_linkage_fn(); - module_linkage_fn(); // expected-error {{declaration of 'module_linkage_fn' must be imported}} - internal_linkage_fn(); // expected-error {{declaration of 'internal_linkage_fn' must be imported}} - (void)external_linkage_class{}; - (void)module_linkage_class{}; // expected-error {{undeclared identifier}} expected-error 0+{{}} - (void)internal_linkage_class{}; // expected-error {{undeclared identifier}} expected-error 0+{{}} - // expected-note@module.cppm:10 {{declaration here is not visible}} - // expected-note@module.cppm:11 {{declaration here is not visible}} - (void)external_linkage_var; - (void)module_linkage_var; // expected-error {{undeclared identifier}} - (void)internal_linkage_var; // expected-error {{undeclared identifier}} -} diff --git a/clang/test/CXX/modules-ts/basic/basic.link/p3.cppm b/clang/test/CXX/modules-ts/basic/basic.link/p3.cppm deleted file mode 100644 index 7e809d7..0000000 --- a/clang/test/CXX/modules-ts/basic/basic.link/p3.cppm +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %clang_cc1 -fmodules-ts -triple x86_64-linux %s -emit-module-interface -o %t -// RUN: %clang_cc1 -fmodules-ts -triple x86_64-linux -x pcm %t -emit-llvm -o - | FileCheck %s - -export module M; - -// CHECK-DAG: @_ZW1M1a ={{.*}} constant i32 1 -const int a = 1; -// CHECK-DAG: @_ZW1M1b ={{.*}} constant i32 2 -export const int b = 2; - -export int f() { return a + b; } diff --git a/clang/test/CXX/modules-ts/basic/basic.search/module-import.cpp b/clang/test/CXX/modules-ts/basic/basic.search/module-import.cpp deleted file mode 100644 index 0b5f39d..0000000 --- a/clang/test/CXX/modules-ts/basic/basic.search/module-import.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// Tests for imported module search. -// -// RUN: rm -rf %t -// RUN: mkdir -p %t -// RUN: echo 'export module x; int a, b;' > %t/x.cppm -// RUN: echo 'export module y; import x; int c;' > %t/y.cppm -// RUN: echo 'export module z; import y; int d;' > %t/z.cppm -// -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %t/x.cppm -o %t/x.pcm -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface -fmodule-file=%t/x.pcm %t/y.cppm -o %t/y.pcm -// -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.pcm -verify %s \ -// RUN: -DMODULE_NAME=x -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/y.pcm -verify %s \ -// RUN: -DMODULE_NAME=y -// -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=x=%t/x.pcm -verify %s \ -// RUN: -DMODULE_NAME=x -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=y=%t/y.pcm -verify %s \ -// RUN: -DMODULE_NAME=y -// -// RUN: mv %t/x.pcm %t/a.pcm -// -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=x=%t/a.pcm -verify %s \ -// RUN: -DMODULE_NAME=x -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/y.pcm -fmodule-file=x=%t/a.pcm -verify %s \ -// RUN: -DMODULE_NAME=y -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=y=%t/y.pcm -fmodule-file=x=%t/a.pcm -verify %s \ -// RUN: -DMODULE_NAME=y -// -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface -fmodule-file=y=%t/y.pcm -fmodule-file=x=%t/a.pcm %t/z.cppm -o %t/z.pcm -// -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=z=%t/z.pcm -fmodule-file=y=%t/y.pcm -fmodule-file=x=%t/a.pcm -verify %s \ -// RUN: -DMODULE_NAME=z -// - -import MODULE_NAME; - -// expected-no-diagnostics diff --git a/clang/test/CXX/modules-ts/codegen-basics.cppm b/clang/test/CXX/modules-ts/codegen-basics.cppm deleted file mode 100644 index cfade9a..0000000 --- a/clang/test/CXX/modules-ts/codegen-basics.cppm +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: %clang_cc1 -fmodules-ts -std=c++1z -triple=x86_64-linux-gnu -fmodules-codegen -emit-module-interface %s -o %t.pcm -// RUN: %clang_cc1 -fmodules-ts -std=c++1z -triple=x86_64-linux-gnu %t.pcm -emit-llvm -o - | FileCheck %s - -export module FooBar; - -export { - // CHECK-DAG: define{{.*}} i32 @_ZW6FooBar1fv( - int f() { return 0; } -} - -// CHECK-DAG: define weak_odr void @_ZW6FooBar2f2v( -inline void f2() {} - -// CHECK-DAG: define{{.*}} void @_ZW6FooBar2f3v( -static void f3() {} -export void use_f3() { f3(); } - -// FIXME: Emit global variables and their initializers with this TU. -// Emit an initialization function that other TUs can call, with guard variable? - -// FIXME: const-qualified variables don't have implicit internal linkage when owned by a module. diff --git a/clang/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.export/p1.cpp b/clang/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.export/p1.cpp deleted file mode 100644 index ab8c690..0000000 --- a/clang/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.export/p1.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// RUN: rm -rf %t -// RUN: mkdir -p %t -// -// RUN: echo 'export module a; export class A{};' | %clang_cc1 -x c++ -fmodules-ts -emit-module-interface - -o %t/a.pcm -// RUN: echo 'export module b; export class B{};' | %clang_cc1 -x c++ -fmodules-ts -emit-module-interface - -o %t/b.pcm -// RUN: echo 'export module c; export class C{};' | %clang_cc1 -x c++ -fmodules-ts -emit-module-interface - -o %t/c.pcm -// -// RUN: %clang_cc1 -fmodules-ts -fprebuilt-module-path=%t -emit-module-interface %s -o %t/aggregate.internal.pcm -DAGGREGATE_INTERNAL -// RUN: %clang_cc1 -fmodules-ts -fprebuilt-module-path=%t -emit-module-interface %s -o %t/aggregate.pcm -DAGGREGATE -// -// RUN: %clang_cc1 -fmodules-ts -fprebuilt-module-path=%t %s -verify -DTEST -// expected-no-diagnostics - - -#ifdef AGGREGATE_INTERNAL -export module aggregate.internal; -export import a; -export { - import b; - import c; -} -#endif - - -// Export the above aggregate module. -// This is done to ensure that re-exports are transitive. -#ifdef AGGREGATE -export module aggregate; -export import aggregate.internal; -#endif - - -// For the actual test, just try using the classes from the exported modules -// and hope that they're accessible. -#ifdef TEST -import aggregate; -A a; -B b; -C c; -#endif diff --git a/clang/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.import/p1.cpp b/clang/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.import/p1.cpp deleted file mode 100644 index 70b553f..0000000 --- a/clang/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.import/p1.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// RUN: rm -rf %t -// RUN: mkdir -p %t -// RUN: echo 'export module x; export int a, b;' > %t/x.cppm -// RUN: echo 'export module x.y; export int c;' > %t/x.y.cppm -// RUN: echo 'export module a.b; export int d;' > %t/a.b.cppm -// -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %t/x.cppm -o %t/x.pcm -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface -fmodule-file=%t/x.pcm %t/x.y.cppm -o %t/x.y.pcm -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %t/a.b.cppm -o %t/a.b.pcm -// -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -fmodule-file=%t/a.b.pcm -verify %s \ -// RUN: -DMODULE_NAME=z -DINTERFACE -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -fmodule-file=%t/a.b.pcm -verify %s \ -// RUN: -DMODULE_NAME=a.b -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -fmodule-file=%t/a.b.pcm -verify %s \ -// RUN: -DMODULE_X -DMODULE_NAME=x - -#ifdef INTERFACE -export -#endif -module MODULE_NAME; - -int use_1 = a; -#if !MODULE_X -// expected-error@-2 {{declaration of 'a' must be imported from module 'x' before it is required}} -// expected-note@x.cppm:1 {{not visible}} -#endif - -import x; - -int use_2 = b; // ok - -// There is no relation between module x and module x.y. -int use_3 = c; // expected-error {{declaration of 'c' must be imported from module 'x.y'}} - // expected-note@x.y.cppm:1 {{not visible}} - -import x [[]]; -import x [[foo]]; // expected-warning {{unknown attribute 'foo' ignored}} -import x [[noreturn]]; // expected-error {{'noreturn' attribute cannot be applied to a module import}} -import x [[blarg::noreturn]]; // expected-warning {{unknown attribute 'noreturn' ignored}} - -import x.y; -import a.b; // Does not imply existence of module a. -import x.; // expected-error {{expected a module name after 'import'}} -import .x; // expected-error {{expected a module name after 'import'}} - -int use_4 = c; // ok - -import blarg; // expected-error {{module 'blarg' not found}} diff --git a/clang/test/CXX/modules-ts/dcl.dcl/dcl.module/p1.cpp b/clang/test/CXX/modules-ts/dcl.dcl/dcl.module/p1.cpp deleted file mode 100644 index 2393aa184..0000000 --- a/clang/test/CXX/modules-ts/dcl.dcl/dcl.module/p1.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -std=c++17 -fmodules-ts -verify %s -DFOO=export -DBAR=export -// RUN: %clang_cc1 -std=c++17 -fmodules-ts -verify %s -DFOO=export -DBAR= -// RUN: %clang_cc1 -std=c++17 -fmodules-ts %s -DFOO=export -emit-module-interface -o %t -// RUN: %clang_cc1 -std=c++17 -fmodules-ts %s -fmodule-file=%t -DFOO= -// RUN: %clang_cc1 -std=c++17 -fmodules-ts %s -fmodule-file=%t -DBAR=export -// RUN: %clang_cc1 -std=c++17 -fmodules-ts -verify %s -fmodule-file=%t -DFOO= -DBAR=export - -#ifdef FOO -FOO module foo; // expected-note {{previous module declaration is here}} -#endif - -#ifdef BAR -BAR module bar; // expected-error {{translation unit contains multiple module declarations}} -#endif diff --git a/clang/test/CodeGenCXX/cxx20-module-nested-1.cppm b/clang/test/CodeGenCXX/cxx20-module-nested-1.cppm index 4b3815c..a87bf04 100644 --- a/clang/test/CodeGenCXX/cxx20-module-nested-1.cppm +++ b/clang/test/CodeGenCXX/cxx20-module-nested-1.cppm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++20 -fmodules-ts %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -std=c++20 %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s module; # 4 __FILE__ 1 namespace Outer::Inner { diff --git a/clang/test/CodeGenCXX/cxx20-module-nested-2.cppm b/clang/test/CodeGenCXX/cxx20-module-nested-2.cppm index 47ba10f..2242294 100644 --- a/clang/test/CodeGenCXX/cxx20-module-nested-2.cppm +++ b/clang/test/CodeGenCXX/cxx20-module-nested-2.cppm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fmodules-ts %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -std=c++20 %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s export module FOO; namespace Outer { class Y; diff --git a/clang/test/Driver/modules-ts.cpp b/clang/test/Driver/modules-ts.cpp deleted file mode 100644 index 30bb9d7..0000000 --- a/clang/test/Driver/modules-ts.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// Check compiling a module interface to a .pcm file. -// -// RUN: %clang -fmodules-ts -x c++-module --precompile %s -o %t.pcm -v 2>&1 | FileCheck %s --check-prefix=CHECK-PRECOMPILE -// -// CHECK-PRECOMPILE: warning: the '-fmodules-ts' flag is deprecated and it will be removed in Clang 17; use '-std=c++20' or higher to use standard C++ modules instead [-Wdeprecated-module-ts] -// CHECK-PRECOMPILE: -cc1 {{.*}} -emit-module-interface -// CHECK-PRECOMPILE-SAME: -o {{.*}}.pcm -// CHECK-PRECOMPILE-SAME: -x c++ -// CHECK-PRECOMPILE-SAME: modules-ts.cpp - -// Check compiling a .pcm file to a .o file. -// -// RUN: %clang -fmodules-ts -fintegrated-as %t.pcm -c -o %t.pcm.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-COMPILE --check-prefix=CHECK-WARN -// -// CHECK-WARN: warning: the '-fmodules-ts' flag is deprecated and it will be removed in Clang 17; use '-std=c++20' or higher to use standard C++ modules instead [-Wdeprecated-module-ts] -// CHECK-COMPILE: -cc1 {{.*}} -emit-obj -// CHECK-COMPILE-SAME: -o {{.*}}.pcm.o -// CHECK-COMPILE-SAME: -x pcm -// CHECK-COMPILE-SAME: {{.*}}.pcm - -// Check use of a .pcm file in another compilation. -// -// RUN: %clang -fmodules-ts -fmodule-file=%t.pcm -fintegrated-as -Dexport= %s -c -o %t.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-USE -// -// CHECK-USE: warning: the '-fmodules-ts' flag is deprecated and it will be removed in Clang 17; use '-std=c++20' or higher to use standard C++ modules instead [-Wdeprecated-module-ts] -// CHECK-USE: -cc1 {{.*}} -emit-obj -// CHECK-USE-SAME: -fmodule-file={{.*}}.pcm -// CHECK-USE-SAME: -o {{.*}}.o{{"?}} {{.*}}-x c++ -// CHECK-USE-SAME: modules-ts.cpp - -// Check combining precompile and compile steps works. -// -// RUN: %clang -fmodules-ts -fintegrated-as -x c++-module %s -c -o %t.pcm.o -v 2>&1 | FileCheck %s --check-prefix=CHECK-PRECOMPILE --check-prefix=CHECK-COMPILE - -// Check that .cppm is treated as a module implicitly. -// RUN: cp %s %t.cppm -// RUN: %clang -fmodules-ts --precompile %t.cppm -o %t.pcm -v 2>&1 | FileCheck %s --check-prefix=CHECK-PRECOMPILE - -// Note, we use -Dexport= to make this a module implementation unit when building the implementation. -export module foo; diff --git a/clang/test/Lexer/modules-ts.cpp b/clang/test/Lexer/modules-ts.cpp deleted file mode 100644 index 06be17c..0000000 --- a/clang/test/Lexer/modules-ts.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only %s -// RUN: %clang_cc1 -fmodules-ts -DMODULES -fsyntax-only %s - -#ifdef MODULES -#define MODULES_KEYWORD(NAME) _Static_assert(!__is_identifier(NAME), #NAME) -#else -#define MODULES_KEYWORD(NAME) _Static_assert(__is_identifier(NAME), #NAME) -#endif - -MODULES_KEYWORD(import); -MODULES_KEYWORD(module); diff --git a/clang/test/Modules/anon-linkage.cpp b/clang/test/Modules/anon-linkage.cpp deleted file mode 100644 index 5906382..0000000 --- a/clang/test/Modules/anon-linkage.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %clang_cc1 -std=c++17 -fmodules-ts %s - -typedef struct { - int c; - union { - int n; - char c[4]; - } v; -} mbstate; - -export module M; -export using ::mbstate; diff --git a/clang/test/Modules/anon-linkage.cppm b/clang/test/Modules/anon-linkage.cppm new file mode 100644 index 0000000..b590f4e --- /dev/null +++ b/clang/test/Modules/anon-linkage.cppm @@ -0,0 +1,21 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: split-file %s %t +// +// RUN: %clang_cc1 -std=c++20 %t/M.cppm -fsyntax-only -verify + +//--- foo.h +typedef struct { + int c; + union { + int n; + char c[4]; + } v; +} mbstate; + +//--- M.cppm +// expected-no-diagnostics +module; +#include "foo.h" +export module M; +export using ::mbstate; diff --git a/clang/test/Modules/diag-flags.cpp b/clang/test/Modules/diag-flags.cpp index 14067c6..4902cc9 100644 --- a/clang/test/Modules/diag-flags.cpp +++ b/clang/test/Modules/diag-flags.cpp @@ -1,34 +1,34 @@ // RUN: rm -rf %t // // For an implicit module, all that matters are the warning flags in the user. -// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -emit-module -fmodules-cache-path=%t -fmodule-name=diag_flags -x c++ %S/Inputs/module.map -fmodules-ts -// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -fmodules-ts -// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -fmodules-ts -DWARNING -DLOCAL_WARNING -Wpadded -// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -fmodules-ts -DERROR -DLOCAL_ERROR -Wpadded -Werror -// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -fmodules-ts -DERROR -DLOCAL_ERROR -Werror=padded +// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -emit-module -fmodules-cache-path=%t -fmodule-name=diag_flags -x c++ %S/Inputs/module.map -std=c++20 +// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -std=c++20 +// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -std=c++20 -DWARNING -DLOCAL_WARNING -Wpadded +// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -std=c++20 -DERROR -DLOCAL_ERROR -Wpadded -Werror +// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -std=c++20 -DERROR -DLOCAL_ERROR -Werror=padded // // For an explicit module, all that matters are the warning flags in the module build. -// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -emit-module -fmodule-name=diag_flags -x c++ %S/Inputs/module.map -fmodules-ts -o %t/nodiag.pcm -// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -fmodules-ts -fmodule-file=%t/nodiag.pcm -Wpadded -DLOCAL_WARNING -// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -fmodules-ts -fmodule-file=%t/nodiag.pcm -Werror -Wpadded -DLOCAL_ERROR +// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -emit-module -fmodule-name=diag_flags -x c++ %S/Inputs/module.map -std=c++20 -o %t/nodiag.pcm +// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -std=c++20 -fmodule-file=%t/nodiag.pcm -Wpadded -DLOCAL_WARNING +// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -std=c++20 -fmodule-file=%t/nodiag.pcm -Werror -Wpadded -DLOCAL_ERROR // -// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -emit-module -fmodule-name=diag_flags -x c++ %S/Inputs/module.map -fmodules-ts -o %t/warning.pcm -Wpadded -// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -fmodules-ts -DWARNING -fmodule-file=%t/warning.pcm -// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -fmodules-ts -DWARNING -fmodule-file=%t/warning.pcm -Werror=padded -DLOCAL_ERROR -// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -fmodules-ts -DWARNING -fmodule-file=%t/warning.pcm -Werror +// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -emit-module -fmodule-name=diag_flags -x c++ %S/Inputs/module.map -std=c++20 -o %t/warning.pcm -Wpadded +// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -std=c++20 -DWARNING -fmodule-file=%t/warning.pcm +// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -std=c++20 -DWARNING -fmodule-file=%t/warning.pcm -Werror=padded -DLOCAL_ERROR +// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -std=c++20 -DWARNING -fmodule-file=%t/warning.pcm -Werror // -// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -emit-module -fmodule-name=diag_flags -x c++ %S/Inputs/module.map -fmodules-ts -o %t/werror-no-error.pcm -Werror -Wpadded -Wno-error=padded -// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -fmodules-ts -DWARNING -fmodule-file=%t/werror-no-error.pcm -// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -fmodules-ts -DWARNING -fmodule-file=%t/werror-no-error.pcm -Wno-padded -// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -fmodules-ts -DWARNING -fmodule-file=%t/werror-no-error.pcm -Werror=padded -DLOCAL_ERROR +// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -emit-module -fmodule-name=diag_flags -x c++ %S/Inputs/module.map -std=c++20 -o %t/werror-no-error.pcm -Werror -Wpadded -Wno-error=padded +// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -std=c++20 -DWARNING -fmodule-file=%t/werror-no-error.pcm +// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -std=c++20 -DWARNING -fmodule-file=%t/werror-no-error.pcm -Wno-padded +// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -std=c++20 -DWARNING -fmodule-file=%t/werror-no-error.pcm -Werror=padded -DLOCAL_ERROR // -// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -emit-module -fmodule-name=diag_flags -x c++ %S/Inputs/module.map -fmodules-ts -o %t/error.pcm -Werror=padded -// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -fmodules-ts -DERROR -fmodule-file=%t/error.pcm -Wno-padded -// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -fmodules-ts -DERROR -fmodule-file=%t/error.pcm -Wno-error=padded +// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -emit-module -fmodule-name=diag_flags -x c++ %S/Inputs/module.map -std=c++20 -o %t/error.pcm -Werror=padded +// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -std=c++20 -DERROR -fmodule-file=%t/error.pcm -Wno-padded +// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -std=c++20 -DERROR -fmodule-file=%t/error.pcm -Wno-error=padded // -// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -emit-module -fmodule-name=diag_flags -x c++ %S/Inputs/module.map -fmodules-ts -o %t/werror.pcm -Werror -Wpadded -// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -fmodules-ts -DERROR -fmodule-file=%t/werror.pcm -Wno-error -// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -fmodules-ts -DERROR -fmodule-file=%t/werror.pcm -Wno-padded +// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -emit-module -fmodule-name=diag_flags -x c++ %S/Inputs/module.map -std=c++20 -o %t/werror.pcm -Werror -Wpadded +// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -std=c++20 -DERROR -fmodule-file=%t/werror.pcm -Wno-error +// RUN: %clang_cc1 -triple %itanium_abi_triple -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -std=c++20 -DERROR -fmodule-file=%t/werror.pcm -Wno-padded import diag_flags; diff --git a/clang/test/Modules/diag-pragma.cpp b/clang/test/Modules/diag-pragma.cpp index 347401f..f2e0206f 100644 --- a/clang/test/Modules/diag-pragma.cpp +++ b/clang/test/Modules/diag-pragma.cpp @@ -1,8 +1,8 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -emit-module -fmodules-cache-path=%t -fmodule-name=diag_pragma -x c++ %S/Inputs/module.map -fmodules-ts -// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -fmodules-ts -// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -emit-module -fmodule-name=diag_pragma -x c++ %S/Inputs/module.map -fmodules-ts -o %t/explicit.pcm -Werror=string-plus-int -// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -fmodules-ts -DEXPLICIT_FLAG -fmodule-file=%t/explicit.pcm +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -emit-module -fmodules-cache-path=%t -fmodule-name=diag_pragma -x c++ %S/Inputs/module.map -std=c++20 +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -std=c++20 +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -emit-module -fmodule-name=diag_pragma -x c++ %S/Inputs/module.map -std=c++20 -o %t/explicit.pcm -Werror=string-plus-int +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -std=c++20 -DEXPLICIT_FLAG -fmodule-file=%t/explicit.pcm import diag_pragma; @@ -42,6 +42,7 @@ int foo(int x) { if (x = DIAG_PRAGMA_MACRO) // expected-warning {{using the result of an assignment as a condition without parentheses}} \ // expected-note {{place parentheses}} expected-note {{use '=='}} + // expected-error@-2 {{use of undeclared identifier 'DIAG_PRAGMA_MACRO'}} return 0; return 1; } diff --git a/clang/test/Modules/import-syntax.c b/clang/test/Modules/import-syntax.c index a29e07a..0e1d74c 100644 --- a/clang/test/Modules/import-syntax.c +++ b/clang/test/Modules/import-syntax.c @@ -7,9 +7,6 @@ // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I%S/Inputs -verify -x objective-c -DAT_IMPORT=1 %s // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I%S/Inputs -verify -x objective-c++ -DAT_IMPORT=1 %s // -// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I%S/Inputs -verify -x c++ -fmodules-ts -DIMPORT=1 %s -// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I%S/Inputs -verify -x objective-c++ -fmodules-ts -DIMPORT=1 %s -// // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I%S/Inputs -verify -x c -DPRAGMA %s // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I%S/Inputs -verify -x objective-c -DPRAGMA %s // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I%S/Inputs -verify -x c++ -DPRAGMA %s @@ -22,8 +19,6 @@ #include "dummy.h" #elif AT_IMPORT @import dummy; -#elif IMPORT -import dummy; #elif PRAGMA #pragma clang module import dummy #endif diff --git a/clang/test/Modules/mismatch-diagnostics.cpp b/clang/test/Modules/mismatch-diagnostics.cpp index 038e367..f8ce987 100644 --- a/clang/test/Modules/mismatch-diagnostics.cpp +++ b/clang/test/Modules/mismatch-diagnostics.cpp @@ -1,22 +1,22 @@ // RUN: rm -rf %t +// RUN: mkdir %t +// RUN: split-file %s %t // RUN: mkdir -p %t/prebuilt_modules // // RUN: %clang_cc1 -triple %itanium_abi_triple \ -// RUN: -fmodules-ts -fprebuilt-module-path=%t/prebuilt-modules \ +// RUN: -std=c++20 -fprebuilt-module-path=%t/prebuilt-modules \ // RUN: -emit-module-interface -pthread -DBUILD_MODULE \ -// RUN: %s -o %t/prebuilt_modules/mismatching_module.pcm +// RUN: %t/mismatching_module.cppm -o \ +// RUN: %t/prebuilt_modules/mismatching_module.pcm // -// RUN: not %clang_cc1 -triple %itanium_abi_triple -fmodules-ts \ +// RUN: not %clang_cc1 -triple %itanium_abi_triple -std=c++20 \ // RUN: -fprebuilt-module-path=%t/prebuilt_modules -DCHECK_MISMATCH \ -// RUN: %s 2>&1 | FileCheck %s +// RUN: %t/use.cpp 2>&1 | FileCheck %s -#ifdef BUILD_MODULE +//--- mismatching_module.cppm export module mismatching_module; -#endif -#ifdef CHECK_MISMATCH +//--- use.cpp import mismatching_module; // CHECK: error: POSIX thread support was enabled in PCH file but is currently disabled // CHECK-NEXT: module file {{.*[/|\\\\]}}mismatching_module.pcm cannot be loaded due to a configuration mismatch with the current compilation -#endif - diff --git a/clang/test/Parser/cxx-modules-interface.cppm b/clang/test/Parser/cxx-modules-interface.cppm index cb63d1c..c5fff64 100644 --- a/clang/test/Parser/cxx-modules-interface.cppm +++ b/clang/test/Parser/cxx-modules-interface.cppm @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -o %t.pcm -verify -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -o %t.pcm -verify -DERRORS +// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -o %t.pcm -verify +// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -o %t.pcm -verify -DERRORS export module foo; #ifndef ERRORS diff --git a/clang/test/SemaCXX/anonymous-union-export.cpp b/clang/test/SemaCXX/anonymous-union-export.cpp index 689c6b9..2e7823f 100644 --- a/clang/test/SemaCXX/anonymous-union-export.cpp +++ b/clang/test/SemaCXX/anonymous-union-export.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++17 -fmodules-ts -emit-obj -verify -o %t.pcm %s +// RUN: %clang_cc1 -std=c++20 -emit-obj -verify -o %t.pcm %s export module M; export { // expected-note 2{{export block begins here}} diff --git a/clang/test/SemaCXX/modules-ts.cppm b/clang/test/SemaCXX/modules.cppm similarity index 67% rename from clang/test/SemaCXX/modules-ts.cppm rename to clang/test/SemaCXX/modules.cppm index 64beb95..0111082 100644 --- a/clang/test/SemaCXX/modules-ts.cppm +++ b/clang/test/SemaCXX/modules.cppm @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -o %t.0.pcm -verify -DTEST=0 -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -o %t.1.pcm -verify -DTEST=1 -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -fmodule-file=%t.0.pcm -o %t.2.pcm -verify -DTEST=2 -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -fmodule-file=%t.0.pcm -o %t.3.pcm -verify -Dfoo=bar -DTEST=3 +// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -o %t.0.pcm -verify -DTEST=0 +// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -o %t.1.pcm -verify -DTEST=1 +// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -fmodule-file=%t.0.pcm -o %t.2.pcm -verify -DTEST=2 +// RUN: %clang_cc1 -std=c++20 -emit-module-interface %s -fmodule-file=%t.0.pcm -o %t.3.pcm -verify -Dfoo=bar -DTEST=3 #if TEST == 0 // expected-no-diagnostics @@ -10,7 +10,7 @@ export module foo; #if TEST == 2 // expected-error@-2 {{redefinition of module 'foo'}} -// expected-note@modules-ts.cppm:* {{loaded from}} +// expected-note@modules.cppm:* {{loaded from}} #endif static int m; @@ -18,14 +18,14 @@ static int m; // expected-error@-2 {{redefinition of '}} // expected-note@-3 {{unguarded header; consider using #ifdef guards or #pragma once}} // FIXME: We should drop the "header from" in this diagnostic. -// expected-note-re@modules-ts.cppm:1 {{'{{.*}}modules-ts.cppm' included multiple times, additional include site in header from module 'foo'}} +// expected-note-re@modules.cppm:1 {{'{{.*}}modules.cppm' included multiple times, additional include site in header from module 'foo'}} #endif int n; #if TEST == 2 // expected-error@-2 {{redefinition of '}} // expected-note@-3 {{unguarded header; consider using #ifdef guards or #pragma once}} // FIXME: We should drop the "header from" in this diagnostic. -// expected-note-re@modules-ts.cppm:1 {{'{{.*}}modules-ts.cppm' included multiple times, additional include site in header from module 'foo'}} +// expected-note-re@modules.cppm:1 {{'{{.*}}modules.cppm' included multiple times, additional include site in header from module 'foo'}} #endif #if TEST == 0 @@ -47,9 +47,9 @@ int use_a = a; // expected-error {{declaration of 'a' must be imported from modu // expected-note@-14 {{declaration here is not visible}} #undef foo -import foo; +import foo; // expected-error {{imports must immediately follow the module declaration}} -export {} // expected-error {{export declaration cannot be empty}} +export {} export { // expected-note {{begins here}} ; // expected-warning {{ISO C++20 does not permit an empty declaration to appear in an export block}} } @@ -78,10 +78,10 @@ struct S { // language rules right now, but (per personal correspondence between zygoloid // and gdr) is the intent. #if TEST == 1 -export { // expected-note {{export block begins here}} +export { extern "C++" { namespace NestedExport { - export { // expected-error {{appears within another export}} + export { // expected-error {{export declaration can only be used within a module interface unit after the module declaration}} int q; } } // namespace NestedExport diff --git a/clang/unittests/AST/DeclTest.cpp b/clang/unittests/AST/DeclTest.cpp index 29072d1..119551b 100644 --- a/clang/unittests/AST/DeclTest.cpp +++ b/clang/unittests/AST/DeclTest.cpp @@ -244,14 +244,14 @@ TEST(Decl, ModuleAndInternalLinkage) { EXPECT_EQ(g->getLinkageInternal(), ModuleLinkage); AST = tooling::buildASTFromCodeWithArgs( - Code.code(), /*Args=*/{"-std=c++20", "-fmodules-ts"}); + Code.code(), /*Args=*/{"-std=c++20"}); ASTContext &CtxTS = AST->getASTContext(); a = selectFirst("a", match(varDecl(hasName("a")).bind("a"), CtxTS)); f = selectFirst( "f", match(functionDecl(hasName("f")).bind("f"), CtxTS)); - EXPECT_EQ(a->getLinkageInternal(), ModuleInternalLinkage); - EXPECT_EQ(f->getLinkageInternal(), ModuleInternalLinkage); + EXPECT_EQ(a->getLinkageInternal(), InternalLinkage); + EXPECT_EQ(f->getLinkageInternal(), InternalLinkage); b = selectFirst("b", match(varDecl(hasName("b")).bind("b"), CtxTS)); g = selectFirst( -- 2.7.4