[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.
This commit is contained in:
Chuanqi Xu 2023-02-16 13:57:25 +08:00
parent fc6d517e2f
commit d54888a3eb
41 changed files with 588 additions and 572 deletions

View File

@ -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.
}

View File

@ -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<typename> extern int var_tpl; // expected-note {{previous declaration is here}}
template<typename> int func_tpl(); // expected-note {{previous declaration is here}}
template<typename> struct str_tpl; // expected-note {{previous declaration is here}}
template<typename> 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<typename> extern int var_tpl; // expected-error {{declaration of 'var_tpl' in module M follows declaration in the global module}}
template<typename> int func_tpl(); // expected-error {{declaration of 'func_tpl' in module M follows declaration in the global module}}
template<typename> struct str_tpl; // expected-error {{declaration of 'str_tpl' in module M follows declaration in the global module}}
template<typename> 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<typename> 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<typename> 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<typename> 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<typename> 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<typename> 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<typename> 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<typename> 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<typename> 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

View File

@ -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

View File

@ -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}}
}

View File

@ -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; }

View File

@ -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

View File

@ -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(); }

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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}}

View File

@ -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

View File

@ -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;
}

View File

@ -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.
}

View File

@ -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<typename> extern int var_tpl; // expected-note {{previous declaration is here}}
template<typename> int func_tpl(); // expected-note {{previous declaration is here}}
template<typename> struct str_tpl; // expected-note {{previous declaration is here}}
template<typename> 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<typename> extern int var_tpl; // expected-error {{declaration of 'var_tpl' in module M follows declaration in the global module}}
template<typename> int func_tpl(); // expected-error {{declaration of 'func_tpl' in module M follows declaration in the global module}}
template<typename> struct str_tpl; // expected-error {{declaration of 'str_tpl' in module M follows declaration in the global module}}
template<typename> 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

View File

@ -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<typename> 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<typename> 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<typename> 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<typename> 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;

View File

@ -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<typename> 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<typename> 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<typename> 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<typename> 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

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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}}
}

View File

@ -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; }

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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}}

View File

@ -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

View File

@ -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 {

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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}}

View File

@ -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

View File

@ -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<VarDecl>("a", match(varDecl(hasName("a")).bind("a"), CtxTS));
f = selectFirst<FunctionDecl>(
"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<VarDecl>("b", match(varDecl(hasName("b")).bind("b"), CtxTS));
g = selectFirst<FunctionDecl>(