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