diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:11:37 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:11:37 +0000 |
| commit | 461a67fa15370a9ec88f8f8a240bf7c123bb2029 (patch) | |
| tree | 6942083d7d56bba40ec790a453ca58ad3baf6832 /test/CXX/modules-ts/basic/basic.def.odr | |
| parent | 75c3240472ba6ac2669ee72ca67eb72d4e2851fc (diff) | |
Notes
Diffstat (limited to 'test/CXX/modules-ts/basic/basic.def.odr')
6 files changed, 156 insertions, 34 deletions
diff --git a/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp b/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp index dc6a3635a8ee..79e68655b45b 100644 --- a/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp +++ b/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp @@ -2,17 +2,14 @@ // 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: @extern_var_exported = external global -// FIXME: Should this be 'external global'? // CHECK-DAG: @inline_var_exported = linkonce_odr global -// CHECK-DAG: @_ZL19static_var_exported = external global -// CHECK-DAG: @const_var_exported = external constant +// CHECK-DAG: @_ZW6ModuleE19static_var_exported = available_externally global i32 0, +// CHECK-DAG: @const_var_exported = available_externally constant i32 3, // -// FIXME: The module name should be mangled into all of these. -// CHECK-DAG: @extern_var_module_linkage = external global -// FIXME: Should this be 'external global'? -// CHECK-DAG: @inline_var_module_linkage = linkonce_odr global -// CHECK-DAG: @_ZL25static_var_module_linkage = external global -// CHECK-DAG: @_ZL24const_var_module_linkage = external constant +// CHECK-DAG: @_ZW6ModuleE25extern_var_module_linkage = external global +// CHECK-DAG: @_ZW6ModuleE25inline_var_module_linkage = linkonce_odr global +// CHECK-DAG: @_ZW6ModuleE25static_var_module_linkage = available_externally global i32 0, +// CHECK-DAG: @_ZW6ModuleE24const_var_module_linkage = available_externally constant i32 3, module Module; @@ -28,15 +25,13 @@ void use() { (void)&const_var_exported; // FIXME: This symbol should not be visible here. - // CHECK: declare {{.*}}@_ZL26used_static_module_linkagev + // CHECK: declare {{.*}}@_ZW6ModuleE26used_static_module_linkagev used_static_module_linkage(); - // FIXME: The module name should be mangled into the name of this function. - // CHECK: define linkonce_odr {{.*}}@_Z26used_inline_module_linkagev + // CHECK: define linkonce_odr {{.*}}@_ZW6ModuleE26used_inline_module_linkagev used_inline_module_linkage(); - // FIXME: The module name should be mangled into the name of this function. - // CHECK: declare {{.*}}@_Z24noninline_module_linkagev + // CHECK: declare {{.*}}@_ZW6ModuleE24noninline_module_linkagev noninline_module_linkage(); (void)&extern_var_module_linkage; diff --git a/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm b/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm index d452f741a0fb..15d1114fb03f 100644 --- a/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm +++ b/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm @@ -11,17 +11,20 @@ // can discard this global and its initializer (if any), and other TUs are not // permitted to run the initializer for this variable. // CHECK-DAG: @inline_var_exported = linkonce_odr global -// CHECK-DAG: @_ZL19static_var_exported = global +// CHECK-DAG: @_ZW6ModuleE19static_var_exported = global // CHECK-DAG: @const_var_exported = constant // -// FIXME: The module name should be mangled into all of these. -// CHECK-DAG: @extern_var_module_linkage = external global +// CHECK-DAG: @_ZW6ModuleE25extern_var_module_linkage = external global // FIXME: Should this be 'weak_odr global'? Presumably it must be, since we // can discard this global and its initializer (if any), and other TUs are not // permitted to run the initializer for this variable. -// CHECK-DAG: @inline_var_module_linkage = linkonce_odr global -// CHECK-DAG: @_ZL25static_var_module_linkage = global -// CHECK-DAG: @_ZL24const_var_module_linkage = constant +// CHECK-DAG: @_ZW6ModuleE25inline_var_module_linkage = linkonce_odr global +// CHECK-DAG: @_ZW6ModuleE25static_var_module_linkage = global +// CHECK-DAG: @_ZW6ModuleE24const_var_module_linkage = constant +// +// CHECK-DAG: @_ZW6ModuleE25unused_var_module_linkage = global i32 4 +// CHECK-DAG: @_ZW6ModuleE32unused_static_var_module_linkage = global i32 5 +// CHECK-DAG: @_ZW6ModuleE31unused_const_var_module_linkage = constant i32 7 static void unused_static_global_module() {} static void used_static_global_module() {} @@ -57,9 +60,9 @@ export module Module; export { // FIXME: These should be ill-formed: you can't export an internal linkage // symbol, per [dcl.module.interface]p2. - // CHECK: define void {{.*}}@_ZL22unused_static_exportedv + // CHECK: define void {{.*}}@_ZW6ModuleE22unused_static_exportedv static void unused_static_exported() {} - // CHECK: define void {{.*}}@_ZL20used_static_exportedv + // CHECK: define void {{.*}}@_ZW6ModuleE20used_static_exportedv static void used_static_exported() {} inline void unused_inline_exported() {} @@ -88,11 +91,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. -// FIXME: The module name should be mangled into the name of this function. -// CHECK: define void {{.*}}@_ZL28unused_static_module_linkagev +// CHECK: define void {{.*}}@_ZW6ModuleE28unused_static_module_linkagev static void unused_static_module_linkage() {} -// FIXME: The module name should be mangled into the name of this function. -// CHECK: define void {{.*}}@_ZL26used_static_module_linkagev +// CHECK: define void {{.*}}@_ZW6ModuleE26used_static_module_linkagev static void used_static_module_linkage() {} inline void unused_inline_module_linkage() {} @@ -103,12 +104,10 @@ inline int inline_var_module_linkage; static int static_var_module_linkage; const int const_var_module_linkage = 3; -// FIXME: The module name should be mangled into the name of this function. -// CHECK: define void {{.*}}@_Z24noninline_module_linkagev +// CHECK: define void {{.*}}@_ZW6ModuleE24noninline_module_linkagev void noninline_module_linkage() { used_static_module_linkage(); - // FIXME: The module name should be mangled into the name of this function. - // CHECK: define linkonce_odr {{.*}}@_Z26used_inline_module_linkagev + // CHECK: define linkonce_odr {{.*}}@_ZW6ModuleE26used_inline_module_linkagev used_inline_module_linkage(); (void)&extern_var_module_linkage; @@ -116,3 +115,15 @@ void noninline_module_linkage() { (void)&static_var_module_linkage; (void)&const_var_module_linkage; } + +int unused_var_module_linkage = 4; +static int unused_static_var_module_linkage = 5; +inline int unused_inline_var_module_linkage = 6; +const int unused_const_var_module_linkage = 7; + +struct a { + struct b {}; + struct c {}; +}; +// CHECK: define void @_ZW6ModuleE1fW_0EN1a1bEW_0ENS_1cE( +void f(a::b, a::c) {} diff --git a/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp b/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp index f6e0238c6b4b..5e9f7ecf5bab 100644 --- a/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp +++ b/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp @@ -2,11 +2,9 @@ // 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: @extern_var_exported = external global -// FIXME: Should this be 'external global'? // CHECK-DAG: @inline_var_exported = linkonce_odr global -// FIXME: These should be 'extern global' and 'extern constant'. -// CHECK-DAG: @_ZL19static_var_exported = global -// CHECK-DAG: @const_var_exported = constant +// CHECK-DAG: @_ZW6ModuleE19static_var_exported = available_externally global i32 0 +// CHECK-DAG: @const_var_exported = available_externally constant i32 3 import Module; diff --git a/test/CXX/modules-ts/basic/basic.def.odr/p6/global-vs-module.cpp b/test/CXX/modules-ts/basic/basic.def.odr/p6/global-vs-module.cpp new file mode 100644 index 000000000000..cceca5106cae --- /dev/null +++ b/test/CXX/modules-ts/basic/basic.def.odr/p6/global-vs-module.cpp @@ -0,0 +1,55 @@ +// 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-re {{{{previous declaration is here|target of using declaration}}}} +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; // expected-note {{using declaration}} +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}} +// FIXME: Is this the right diagnostic in the -DUSING case? +template<typename> int func_tpl(); // expected-error-re {{{{declaration of 'func_tpl' in module M follows declaration in the global module|conflicts with target of using declaration}}}} +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 diff --git a/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-global.cpp b/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-global.cpp new file mode 100644 index 000000000000..f58506dd9c46 --- /dev/null +++ b/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-global.cpp @@ -0,0 +1,19 @@ +// 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:45 {{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:46 {{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:47 {{previous}} + +typedef int type; +namespace ns { using ::func; } +namespace ns_alias = ns; diff --git a/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-module.cpp b/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-module.cpp new file mode 100644 index 000000000000..39e210c4ad80 --- /dev/null +++ b/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-module.cpp @@ -0,0 +1,44 @@ +// 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:45 {{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:46 {{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:47 {{previous}} + +typedef int type; +namespace ns { using ::func; } +namespace ns_alias = ns; +#endif |
