| 1 | // RUN: %clang_cc1 -fmodules-ts -verify -std=c++17 %s |
| 2 | // RUN: %clang_cc1 -fmodules-ts -verify -std=c++17 %s -DEXPORT |
| 3 | // RUN: %clang_cc1 -fmodules-ts -verify -std=c++17 %s -DUSING |
| 4 | |
| 5 | #ifndef NO_GLOBAL |
| 6 | extern int var; // expected-note {{previous declaration is here}} |
| 7 | int func(); // expected-note {{previous declaration is here}} |
| 8 | struct str; // expected-note {{previous declaration is here}} |
| 9 | using type = int; |
| 10 | |
| 11 | template<typename> extern int var_tpl; // expected-note {{previous declaration is here}} |
| 12 | template<typename> int func_tpl(); // expected-note-re {{{{previous declaration is here|target of using declaration}}}} |
| 13 | template<typename> struct str_tpl; // expected-note {{previous declaration is here}} |
| 14 | template<typename> using type_tpl = int; // expected-note {{previous declaration is here}} |
| 15 | |
| 16 | typedef int type; |
| 17 | namespace ns { using ::func; } |
| 18 | namespace ns_alias = ns; |
| 19 | #endif |
| 20 | |
| 21 | export module M; |
| 22 | |
| 23 | #ifdef USING |
| 24 | using ::var; |
| 25 | using ::func; |
| 26 | using ::str; |
| 27 | using ::type; |
| 28 | using ::var_tpl; |
| 29 | using ::func_tpl; // expected-note {{using declaration}} |
| 30 | using ::str_tpl; |
| 31 | using ::type_tpl; |
| 32 | #endif |
| 33 | |
| 34 | #ifdef EXPORT |
| 35 | export { |
| 36 | #endif |
| 37 | |
| 38 | extern int var; // expected-error {{declaration of 'var' in module M follows declaration in the global module}} |
| 39 | int func(); // expected-error {{declaration of 'func' in module M follows declaration in the global module}} |
| 40 | struct str; // expected-error {{declaration of 'str' in module M follows declaration in the global module}} |
| 41 | using type = int; |
| 42 | |
| 43 | template<typename> extern int var_tpl; // expected-error {{declaration of 'var_tpl' in module M follows declaration in the global module}} |
| 44 | // FIXME: Is this the right diagnostic in the -DUSING case? |
| 45 | 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}}}} |
| 46 | template<typename> struct str_tpl; // expected-error {{declaration of 'str_tpl' in module M follows declaration in the global module}} |
| 47 | template<typename> using type_tpl = int; // expected-error {{declaration of 'type_tpl' in module M follows declaration in the global module}} |
| 48 | |
| 49 | typedef int type; |
| 50 | namespace ns { using ::func; } |
| 51 | namespace ns_alias = ns; |
| 52 | |
| 53 | #ifdef EXPORT |
| 54 | } |
| 55 | #endif |
| 56 | |