| 1 | // RUN: rm -rf %t |
| 2 | // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/submodules-merge-defs %s -verify -fno-modules-error-recovery -DTEXTUAL |
| 3 | // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/submodules-merge-defs %s -verify -fno-modules-error-recovery |
| 4 | // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/submodules-merge-defs %s -verify -fno-modules-error-recovery -fmodules-local-submodule-visibility -DTEXTUAL |
| 5 | // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/submodules-merge-defs %s -verify -fno-modules-error-recovery -fmodules-local-submodule-visibility |
| 6 | // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules-cache-path=%t -fimplicit-module-maps -I %S/Inputs/submodules-merge-defs %s -verify -fno-modules-error-recovery -fmodules-local-submodule-visibility -DTEXTUAL -DEARLY_INDIRECT_INCLUDE |
| 7 | // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/submodules-merge-defs %s -verify -fno-modules-error-recovery -fmodules-local-submodule-visibility -fmodule-feature use_defs_twice -DIMPORT_USE_2 |
| 8 | |
| 9 | // Trigger import of definitions, but don't make them visible. |
| 10 | #include "empty.h" |
| 11 | #ifdef EARLY_INDIRECT_INCLUDE |
| 12 | #include "indirect.h" |
| 13 | #endif |
| 14 | |
| 15 | A pre_a; |
| 16 | #ifdef IMPORT_USE_2 |
| 17 | // expected-error-re@-2 {{must be imported from one of {{.*}}stuff.use{{.*}}stuff.use-2}} |
| 18 | #elif EARLY_INDIRECT_INCLUDE |
| 19 | // expected-error@-4 {{must be imported from module 'merged-defs'}} |
| 20 | #else |
| 21 | // expected-error@-6 {{must be imported from module 'stuff.use'}} |
| 22 | #endif |
| 23 | // expected-note@defs.h:1 +{{here}} |
| 24 | extern class A pre_a2; |
| 25 | int pre_use_a = use_a(pre_a2); // expected-error 2{{'A' must be imported}} expected-error {{'use_a' must be imported}} |
| 26 | // expected-note@defs.h:2 +{{here}} |
| 27 | |
| 28 | B::Inner2 pre_bi; // expected-error +{{must be imported}} |
| 29 | // expected-note@defs.h:4 +{{here}} |
| 30 | // expected-note@defs.h:17 +{{here}} |
| 31 | void pre_bfi(B b) { // expected-error +{{must be imported}} |
| 32 | b.f<int>(); // expected-error +{{}} |
| 33 | } |
| 34 | |
| 35 | C_Base<1> pre_cb1; // expected-error +{{must be imported}} |
| 36 | // expected-note@defs.h:23 +{{here}} |
| 37 | C1 pre_c1; // expected-error +{{must be imported}} |
| 38 | // expected-note@defs.h:25 +{{here}} |
| 39 | C2 pre_c2; // expected-error +{{must be imported}} |
| 40 | // expected-note@defs.h:26 +{{here}} |
| 41 | |
| 42 | D::X pre_dx; // expected-error +{{must be imported}} |
| 43 | // expected-note@defs.h:28 +{{here}} |
| 44 | // expected-note@defs.h:29 +{{here}} |
| 45 | int pre_use_dx = use_dx(pre_dx); // ignored; pre_dx is invalid |
| 46 | |
| 47 | int pre_e = E(0); // expected-error {{must be imported}} |
| 48 | // expected-note@defs.h:32 +{{here}} |
| 49 | |
| 50 | int pre_ff = F<int>().f(); // expected-error +{{must be imported}} |
| 51 | int pre_fg = F<int>().g<int>(); // expected-error +{{must be imported}} expected-error 2{{expected}} |
| 52 | // expected-note@defs.h:34 +{{here}} |
| 53 | |
| 54 | G::A pre_ga // expected-error +{{must be imported}} |
| 55 | = G::a; // expected-error +{{must be imported}} |
| 56 | // expected-note@defs.h:49 +{{here}} |
| 57 | // expected-note@defs.h:50 +{{here}} |
| 58 | decltype(G::h) pre_gh = G::h; // expected-error +{{must be imported}} |
| 59 | // expected-note@defs.h:51 +{{here}} |
| 60 | |
| 61 | int pre_h = H(); // expected-error +{{must be imported}} |
| 62 | // expected-note@defs.h:56 +{{here}} |
| 63 | using pre_i = I<>; // expected-error +{{must be imported}} |
| 64 | // expected-note@defs.h:57 +{{here}} |
| 65 | |
| 66 | J<> pre_j; // expected-error {{declaration of 'J' must be imported}} |
| 67 | #ifdef IMPORT_USE_2 |
| 68 | // expected-error-re@-2 {{default argument of 'J' must be imported from one of {{.*}}stuff.use-2{{.*}}stuff.use}} |
| 69 | #elif EARLY_INDIRECT_INCLUDE |
| 70 | // expected-error@-4 {{default argument of 'J' must be imported from module 'merged-defs'}} |
| 71 | #else |
| 72 | // expected-error@-6 {{default argument of 'J' must be imported from module 'stuff.use'}} |
| 73 | #endif |
| 74 | // expected-note@defs.h:58 +{{here}} |
| 75 | |
| 76 | ScopedEnum pre_scopedenum; // expected-error {{must be imported}} |
| 77 | // expected-note@defs.h:105 0-1{{here}} |
| 78 | // expected-note@defs.h:106 0-1{{here}} |
| 79 | enum ScopedEnum : int; |
| 80 | ScopedEnum pre_scopedenum_declared; // ok |
| 81 | |
| 82 | // Make definitions from second module visible. |
| 83 | #ifdef TEXTUAL |
| 84 | #include "import-and-redefine.h" |
| 85 | #elif defined IMPORT_USE_2 |
| 86 | #include "use-defs-2.h" |
| 87 | #else |
| 88 | #include "merged-defs.h" |
| 89 | #endif |
| 90 | |
| 91 | A post_a; |
| 92 | int post_use_a = use_a(post_a); |
| 93 | B::Inner2 post_bi; |
| 94 | void post_bfi(B b) { |
| 95 | b.f<int>(); |
| 96 | } |
| 97 | C_Base<1> post_cb1; |
| 98 | C1 c1; |
| 99 | C2 c2; |
| 100 | D::X post_dx; |
| 101 | int post_use_dx = use_dx(post_dx); |
| 102 | int post_e = E(0); |
| 103 | int post_ff = F<char>().f(); |
| 104 | int post_fg = F<char>().g<int>(); |
| 105 | G::A post_ga = G::a; |
| 106 | decltype(G::h) post_gh = G::h; |
| 107 | int post_h = H(); |
| 108 | using post_i = I<>; |
| 109 | J<> post_j; |
| 110 | template<typename T, int N, template<typename> class K> struct J; |
| 111 | J<> post_j2; |
| 112 | FriendDefArg::Y<int> friend_def_arg; |
| 113 | FriendDefArg::D<> friend_def_arg_d; |
| 114 | int post_anon_x_n = Anon::X().n; |
| 115 | |
| 116 | MergeFunctionTemplateSpecializations::X<int>::Q<char> xiqc; |
| 117 | |
| 118 | #ifdef TEXTUAL |
| 119 | #include "use-defs.h" |
| 120 | void use_static_inline() { StaticInline::g({}); } |
| 121 | #ifdef EARLY_INDIRECT_INCLUDE |
| 122 | // expected-warning@-2 {{ambiguous use of internal linkage declaration 'g' defined in multiple modules}} |
| 123 | // expected-note@defs.h:71 {{declared here in module 'redef'}} |
| 124 | // expected-note@defs.h:71 {{declared here in module 'stuff.use'}} |
| 125 | #endif |
| 126 | int use_anon_enum = G::g; |
| 127 | #ifdef EARLY_INDIRECT_INCLUDE |
| 128 | // expected-warning@-2 3{{ambiguous use of internal linkage declaration 'g' defined in multiple modules}} |
| 129 | // FIXME: These notes are produced, but -verify can't match them? |
| 130 | // FIXME-note@defs.h:51 3{{declared here in module 'redef'}} |
| 131 | // FIXME-note@defs.h:51 3{{declared here in module 'stuff.use'}} |
| 132 | #endif |
| 133 | int use_named_enum = G::i; |
| 134 | #endif |
| 135 | |