brintos

brintos / llvm-project-archived public Read only

0
0
Text · 11.3 KiB · c532e7a Raw
218 lines · plain
1// RUN: rm -rf %t2// RUN: mkdir %t3// RUN: split-file %s %t4//5// RUN: %clang_cc1 -std=c++20 -verify %t/global-vs-module.cppm 6// RUN: %clang_cc1 -std=c++20 -verify %t/global-vs-module-export.cppm7// RUN: %clang_cc1 -std=c++20 -verify %t/global-vs-module-using.cppm8//9// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/M.cppm -o %t/M.pcm10// RUN: %clang_cc1 -std=c++20 -verify %t/module-vs-global.cpp -fmodule-file=M=%t/M.pcm11//12// Some of the following tests intentionally have no -verify in their RUN13// lines; we are testing that those cases do not produce errors.14//15// RUN: %clang_cc1 -std=c++20 %t/module-vs-module-interface.cpp -fmodule-file=M=%t/M.pcm -verify16// RUN: %clang_cc1 -std=c++20 %t/module-vs-module-interface.cpp -fmodule-file=M=%t/M.pcm -DNO_IMPORT17//18// RUN: %clang_cc1 -std=c++20 %t/module-vs-module-interface.cpp -fmodule-file=M=%t/M.pcm -emit-module-interface -o %t/N.pcm -DNO_ERRORS19// RUN: %clang_cc1 -std=c++20 %t/module-vs-module-impl.cpp -fmodule-file=M=%t/M.pcm -fmodule-file=N=%t/N.pcm -verify20//21// RUN: %clang_cc1 -std=c++20 %t/module-vs-module-impl.cpp -fmodule-file=M=%t/M.pcm -fmodule-file=N=%t/N.pcm -DNO_IMPORT -verify22//23// RUN: %clang_cc1 -std=c++20 %t/module-vs-module-interface.cpp -fmodule-file=M=%t/M.pcm -emit-module-interface -o %t/N-no-M.pcm -DNO_ERRORS -DNO_IMPORT24// RUN: %clang_cc1 -std=c++20 %t/module-vs-module-impl.cpp -fmodule-file=M=%t/M.pcm -fmodule-file=N=%t/N-no-M.pcm -verify25// RUN: %clang_cc1 -std=c++20 %t/module-vs-module-impl.cpp -fmodule-file=N=%t/N-no-M.pcm -DNO_IMPORT26 27//--- global-vs-module.cppm28module;29extern int var; // expected-note {{previous declaration is here}}30int func(); // expected-note {{previous declaration is here}}31struct str; // expected-note {{previous declaration is here}}32using type = int;33 34template<typename> extern int var_tpl; // expected-note {{previous declaration is here}}35template<typename> int func_tpl(); // expected-note {{previous declaration is here}}36template<typename> struct str_tpl; // expected-note {{previous declaration is here}}37template<typename> using type_tpl = int; // expected-note {{previous declaration is here}}38 39typedef int type;40namespace ns { using ::func; }41namespace ns_alias = ns;42 43export module M;44 45extern int var; // expected-error {{declaration of 'var' in module M follows declaration in the global module}}46int func(); // expected-error {{declaration of 'func' in module M follows declaration in the global module}}47struct str; // expected-error {{declaration of 'str' in module M follows declaration in the global module}}48using type = int;49 50template<typename> extern int var_tpl; // expected-error {{declaration of 'var_tpl' in module M follows declaration in the global module}}51template<typename> int func_tpl(); // expected-error {{declaration of 'func_tpl' in module M follows declaration in the global module}}52template<typename> struct str_tpl; // expected-error {{declaration of 'str_tpl' in module M follows declaration in the global module}}53template<typename> using type_tpl = int; // expected-error {{declaration of 'type_tpl' in module M follows declaration in the global module}}54 55typedef int type;56namespace ns { using ::func; }57namespace ns_alias = ns;58 59//--- global-vs-module-export.cppm60module;61extern int var; // expected-note {{previous declaration is here}}62int func(); // expected-note {{previous declaration is here}}63struct str; // expected-note {{previous declaration is here}}64using type = int;65 66template<typename> extern int var_tpl; // expected-note {{previous declaration is here}}67template<typename> int func_tpl(); // expected-note {{previous declaration is here}}68template<typename> struct str_tpl; // expected-note {{previous declaration is here}}69template<typename> using type_tpl = int; // expected-note {{previous declaration is here}}70 71typedef int type;72namespace ns { using ::func; }73namespace ns_alias = ns;74 75export module M;76 77export {78extern int var; // expected-error {{declaration of 'var' in module M follows declaration in the global module}}79int func(); // expected-error {{declaration of 'func' in module M follows declaration in the global module}}80struct str; // expected-error {{declaration of 'str' in module M follows declaration in the global module}}81using type = int;82 83template<typename> extern int var_tpl; // expected-error {{declaration of 'var_tpl' in module M follows declaration in the global module}}84template<typename> int func_tpl(); // expected-error {{declaration of 'func_tpl' in module M follows declaration in the global module}}85template<typename> struct str_tpl; // expected-error {{declaration of 'str_tpl' in module M follows declaration in the global module}}86template<typename> using type_tpl = int; // expected-error {{declaration of 'type_tpl' in module M follows declaration in the global module}}87 88typedef int type;89namespace ns { using ::func; }90namespace ns_alias = ns;91}92 93//--- global-vs-module-using.cppm94module;95extern int var; // expected-note {{previous declaration is here}}96int func(); // expected-note {{previous declaration is here}}97struct str; // expected-note {{previous declaration is here}}98using type = int;99 100template<typename> extern int var_tpl; // expected-note {{previous declaration is here}}101template<typename> int func_tpl(); // expected-note {{previous declaration is here}}102template<typename> struct str_tpl; // expected-note {{previous declaration is here}}103template<typename> using type_tpl = int; // expected-note {{previous declaration is here}}104 105typedef int type;106namespace ns { using ::func; }107namespace ns_alias = ns;108 109export module M;110 111using ::var;112using ::func;113using ::str;114using ::type;115using ::var_tpl;116using ::func_tpl;117using ::str_tpl;118using ::type_tpl;119 120extern int var; // expected-error {{declaration of 'var' in module M follows declaration in the global module}}121int func(); // expected-error {{declaration of 'func' in module M follows declaration in the global module}}122struct str; // expected-error {{declaration of 'str' in module M follows declaration in the global module}}123using type = int;124 125template<typename> extern int var_tpl; // expected-error {{declaration of 'var_tpl' in module M follows declaration in the global module}}126template<typename> int func_tpl(); // expected-error {{declaration of 'func_tpl' in module M follows declaration in the global module}}127template<typename> struct str_tpl; // expected-error {{declaration of 'str_tpl' in module M follows declaration in the global module}}128template<typename> using type_tpl = int; // expected-error {{declaration of 'type_tpl' in module M follows declaration in the global module}}129 130typedef int type;131namespace ns { using ::func; }132namespace ns_alias = ns;133 134//--- M.cppm135export module M;136 137export {138extern int var; // expected-error {{declaration of 'var' in module M follows declaration in the global module}}139int func(); // expected-error {{declaration of 'func' in module M follows declaration in the global module}}140struct str; // expected-error {{declaration of 'str' in module M follows declaration in the global module}}141using type = int;142 143template<typename> extern int var_tpl; // expected-error {{declaration of 'var_tpl' in module M follows declaration in the global module}}144template<typename> int func_tpl(); // expected-error {{declaration of 'func_tpl' in module M follows declaration in the global module}}145template<typename> struct str_tpl; // expected-error {{declaration of 'str_tpl' in module M follows declaration in the global module}}146template<typename> using type_tpl = int; // expected-error {{declaration of 'type_tpl' in module M follows declaration in the global module}}147 148typedef int type;149namespace ns { using ::func; }150namespace ns_alias = ns;151}152 153//--- module-vs-global.cpp154module;155import M;156 157extern int var; // expected-error {{declaration of 'var' in the global module follows declaration in module M}} expected-note@M.cppm:4 {{previous}}158int func(); // expected-error {{declaration of 'func' in the global module follows declaration in module M}} expected-note@M.cppm:5 {{previous}}159struct str; // expected-error {{declaration of 'str' in the global module follows declaration in module M}} expected-note@M.cppm:6 {{previous}}160using type = int;161 162template<typename> extern int var_tpl; // expected-error {{declaration of 'var_tpl' in the global module follows declaration in module M}} expected-note@M.cppm:9 {{previous}}163template<typename> int func_tpl(); // expected-error {{declaration of 'func_tpl' in the global module follows declaration in module M}} expected-note@M.cppm:10 {{previous}}164template<typename> struct str_tpl; // expected-error {{declaration of 'str_tpl' in the global module follows declaration in module M}} expected-note@M.cppm:11 {{previous}}165template<typename> using type_tpl = int; // expected-error {{declaration of 'type_tpl' in the global module follows declaration in module M}} expected-note@M.cppm:12 {{previous}}166 167typedef int type;168namespace ns { using ::func; }169namespace ns_alias = ns;170 171export module N;172 173//--- module-vs-module-interface.cpp174export module N;175 176#ifndef NO_IMPORT177import M;178#endif179 180#ifndef NO_ERRORS181extern int var; // expected-error {{declaration of 'var' in module N follows declaration in module M}} expected-note@M.cppm:4 {{previous}}182int func(); // expected-error {{declaration of 'func' in module N follows declaration in module M}} expected-note@M.cppm:5 {{previous}}183struct str; // expected-error {{declaration of 'str' in module N follows declaration in module M}} expected-note@M.cppm:6 {{previous}}184using type = int;185 186template<typename> extern int var_tpl; // expected-error {{declaration of 'var_tpl' in module N follows declaration in module M}} expected-note@M.cppm:9 {{previous}}187template<typename> int func_tpl(); // expected-error {{declaration of 'func_tpl' in module N follows declaration in module M}} expected-note@M.cppm:10 {{previous}}188template<typename> struct str_tpl; // expected-error {{declaration of 'str_tpl' in module N follows declaration in module M}} expected-note@M.cppm:11 {{previous}}189template<typename> using type_tpl = int; // expected-error {{declaration of 'type_tpl' in module N follows declaration in module M}} expected-note@M.cppm:12 {{previous}}190 191typedef int type;192namespace ns { using ::func; }193namespace ns_alias = ns;194#endif195 196//--- module-vs-module-impl.cpp197module N;198 199#ifndef NO_IMPORT200import M;201#endif202 203#ifndef NO_ERRORS204extern int var; // expected-error {{declaration of 'var' in module N follows declaration in module M}} expected-note@M.cppm:4 {{previous}}205int func(); // expected-error {{declaration of 'func' in module N follows declaration in module M}} expected-note@M.cppm:5 {{previous}}206struct str; // expected-error {{declaration of 'str' in module N follows declaration in module M}} expected-note@M.cppm:6 {{previous}}207using type = int;208 209template<typename> extern int var_tpl; // expected-error {{declaration of 'var_tpl' in module N follows declaration in module M}} expected-note@M.cppm:9 {{previous}}210template<typename> int func_tpl(); // expected-error {{declaration of 'func_tpl' in module N follows declaration in module M}} expected-note@M.cppm:10 {{previous}}211template<typename> struct str_tpl; // expected-error {{declaration of 'str_tpl' in module N follows declaration in module M}} expected-note@M.cppm:11 {{previous}}212template<typename> using type_tpl = int; // expected-error {{declaration of 'type_tpl' in module N follows declaration in module M}} expected-note@M.cppm:12 {{previous}}213 214typedef int type;215namespace ns { using ::func; }216namespace ns_alias = ns;217#endif218