Richard Smith | 65ebb4a | 2015-03-26 04:09:53 +0000 | [diff] [blame] | 1 | // RUN: rm -rf %t |
Richard Smith | 47972af | 2015-06-16 00:08:24 +0000 | [diff] [blame] | 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 |
Richard Smith | 529ecb2 | 2015-06-22 21:15:01 +0000 | [diff] [blame] | 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 -fno-modules-hide-internal-linkage |
Richard Smith | 47972af | 2015-06-16 00:08:24 +0000 | [diff] [blame] | 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 |
Richard Smith | 65ebb4a | 2015-03-26 04:09:53 +0000 | [diff] [blame] | 8 | |
| 9 | // Trigger import of definitions, but don't make them visible. |
| 10 | #include "empty.h" |
Richard Smith | 00be6d0 | 2015-06-11 03:05:39 +0000 | [diff] [blame] | 11 | #ifdef EARLY_INDIRECT_INCLUDE |
| 12 | #include "indirect.h" |
| 13 | #endif |
Richard Smith | 65ebb4a | 2015-03-26 04:09:53 +0000 | [diff] [blame] | 14 | |
Richard Smith | f2b1eb9 | 2015-06-15 20:15:48 +0000 | [diff] [blame] | 15 | A pre_a; // expected-error {{must use 'struct'}} |
| 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 |
Richard Smith | 9a71c99 | 2015-03-27 20:16:58 +0000 | [diff] [blame] | 23 | // expected-note@defs.h:1 +{{here}} |
Richard Smith | a143107 | 2015-06-12 01:32:13 +0000 | [diff] [blame] | 24 | // expected-note@defs.h:2 +{{here}} |
| 25 | int pre_use_a = use_a(pre_a); // expected-error {{'A' must be imported}} expected-error {{'use_a' must be imported}} |
Richard Smith | 65ebb4a | 2015-03-26 04:09:53 +0000 | [diff] [blame] | 26 | |
Richard Smith | be3980b | 2015-03-27 00:41:57 +0000 | [diff] [blame] | 27 | B::Inner2 pre_bi; // expected-error +{{must be imported}} |
| 28 | // expected-note@defs.h:4 +{{here}} |
Richard Smith | d6aab59 | 2015-03-27 21:57:41 +0000 | [diff] [blame] | 29 | // expected-note@defs.h:11 +{{here}} |
Richard Smith | 5327b89 | 2015-07-01 19:32:54 +0000 | [diff] [blame] | 30 | void pre_bfi(B b) { // expected-error {{must use 'class'}} expected-error +{{must be imported}} |
| 31 | b.f<int>(); // expected-error +{{must be imported}} expected-error +{{}} |
| 32 | // expected-note@defs.h:12 +{{here}} |
| 33 | } |
Richard Smith | be3980b | 2015-03-27 00:41:57 +0000 | [diff] [blame] | 34 | |
| 35 | C_Base<1> pre_cb1; // expected-error +{{must be imported}} |
Richard Smith | 5327b89 | 2015-07-01 19:32:54 +0000 | [diff] [blame] | 36 | // expected-note@defs.h:16 +{{here}} |
Richard Smith | d6aab59 | 2015-03-27 21:57:41 +0000 | [diff] [blame] | 37 | C1 pre_c1; // expected-error +{{must be imported}} expected-error {{must use 'struct'}} |
Richard Smith | d6aab59 | 2015-03-27 21:57:41 +0000 | [diff] [blame] | 38 | // expected-note@defs.h:18 +{{here}} |
Richard Smith | 5327b89 | 2015-07-01 19:32:54 +0000 | [diff] [blame] | 39 | C2 pre_c2; // expected-error +{{must be imported}} expected-error {{must use 'struct'}} |
| 40 | // expected-note@defs.h:19 +{{here}} |
Richard Smith | be3980b | 2015-03-27 00:41:57 +0000 | [diff] [blame] | 41 | |
Richard Smith | a523022 | 2015-03-27 01:37:43 +0000 | [diff] [blame] | 42 | D::X pre_dx; // expected-error +{{must be imported}} |
Richard Smith | d6aab59 | 2015-03-27 21:57:41 +0000 | [diff] [blame] | 43 | // expected-note@defs.h:21 +{{here}} |
Richard Smith | 5327b89 | 2015-07-01 19:32:54 +0000 | [diff] [blame] | 44 | // expected-note@defs.h:22 +{{here}} |
Richard Smith | 9a71c99 | 2015-03-27 20:16:58 +0000 | [diff] [blame] | 45 | // FIXME: We should warn that use_dx is being used without being imported. |
| 46 | int pre_use_dx = use_dx(pre_dx); |
Richard Smith | a523022 | 2015-03-27 01:37:43 +0000 | [diff] [blame] | 47 | |
Richard Smith | d6aab59 | 2015-03-27 21:57:41 +0000 | [diff] [blame] | 48 | int pre_e = E(0); // expected-error {{must be imported}} |
Richard Smith | 5327b89 | 2015-07-01 19:32:54 +0000 | [diff] [blame] | 49 | // expected-note@defs.h:25 +{{here}} |
Richard Smith | d6aab59 | 2015-03-27 21:57:41 +0000 | [diff] [blame] | 50 | |
| 51 | int pre_ff = F<int>().f(); // expected-error +{{must be imported}} |
| 52 | int pre_fg = F<int>().g<int>(); // expected-error +{{must be imported}} |
Richard Smith | 5327b89 | 2015-07-01 19:32:54 +0000 | [diff] [blame] | 53 | // expected-note@defs.h:27 +{{here}} |
Richard Smith | d6aab59 | 2015-03-27 21:57:41 +0000 | [diff] [blame] | 54 | |
Richard Smith | 75ea855 | 2015-06-17 23:07:50 +0000 | [diff] [blame] | 55 | G::A pre_ga // expected-error +{{must be imported}} |
| 56 | = G::a; // expected-error +{{must be imported}} |
Richard Smith | 75ea855 | 2015-06-17 23:07:50 +0000 | [diff] [blame] | 57 | // expected-note@defs.h:42 +{{here}} |
Richard Smith | 5327b89 | 2015-07-01 19:32:54 +0000 | [diff] [blame] | 58 | // expected-note@defs.h:43 +{{here}} |
| 59 | decltype(G::h) pre_gh = G::h; // expected-error +{{must be imported}} |
| 60 | // expected-note@defs.h:44 +{{here}} |
Richard Smith | 75ea855 | 2015-06-17 23:07:50 +0000 | [diff] [blame] | 61 | |
Richard Smith | 35c1df5 | 2015-06-17 20:16:32 +0000 | [diff] [blame] | 62 | J<> pre_j; // expected-error {{declaration of 'J' must be imported}} |
| 63 | #ifdef IMPORT_USE_2 |
Richard Smith | 63e09bf | 2015-06-17 20:39:41 +0000 | [diff] [blame] | 64 | // expected-error-re@-2 {{default argument of 'J' must be imported from one of {{.*}}stuff.use{{.*}}stuff.use-2}} |
Richard Smith | 35c1df5 | 2015-06-17 20:16:32 +0000 | [diff] [blame] | 65 | #elif EARLY_INDIRECT_INCLUDE |
Richard Smith | 63e09bf | 2015-06-17 20:39:41 +0000 | [diff] [blame] | 66 | // expected-error@-4 {{default argument of 'J' must be imported from module 'merged-defs'}} |
Richard Smith | 35c1df5 | 2015-06-17 20:16:32 +0000 | [diff] [blame] | 67 | #else |
Richard Smith | 63e09bf | 2015-06-17 20:39:41 +0000 | [diff] [blame] | 68 | // expected-error@-6 {{default argument of 'J' must be imported from module 'stuff.use'}} |
Richard Smith | 35c1df5 | 2015-06-17 20:16:32 +0000 | [diff] [blame] | 69 | #endif |
Richard Smith | 5327b89 | 2015-07-01 19:32:54 +0000 | [diff] [blame] | 70 | // expected-note@defs.h:51 +{{here}} |
Richard Smith | c785276 | 2015-06-11 23:46:11 +0000 | [diff] [blame] | 71 | |
Richard Smith | 65ebb4a | 2015-03-26 04:09:53 +0000 | [diff] [blame] | 72 | // Make definitions from second module visible. |
Richard Smith | 0279375 | 2015-03-27 21:16:39 +0000 | [diff] [blame] | 73 | #ifdef TEXTUAL |
Richard Smith | 65ebb4a | 2015-03-26 04:09:53 +0000 | [diff] [blame] | 74 | #include "import-and-redefine.h" |
Richard Smith | f2b1eb9 | 2015-06-15 20:15:48 +0000 | [diff] [blame] | 75 | #elif defined IMPORT_USE_2 |
| 76 | #include "use-defs-2.h" |
Richard Smith | 0279375 | 2015-03-27 21:16:39 +0000 | [diff] [blame] | 77 | #else |
| 78 | #include "merged-defs.h" |
| 79 | #endif |
Richard Smith | 65ebb4a | 2015-03-26 04:09:53 +0000 | [diff] [blame] | 80 | |
| 81 | A post_a; |
Richard Smith | 9a71c99 | 2015-03-27 20:16:58 +0000 | [diff] [blame] | 82 | int post_use_a = use_a(post_a); |
Richard Smith | be3980b | 2015-03-27 00:41:57 +0000 | [diff] [blame] | 83 | B::Inner2 post_bi; |
Richard Smith | 5327b89 | 2015-07-01 19:32:54 +0000 | [diff] [blame] | 84 | void post_bfi(B b) { |
| 85 | b.f<int>(); |
| 86 | } |
Richard Smith | be3980b | 2015-03-27 00:41:57 +0000 | [diff] [blame] | 87 | C_Base<1> post_cb1; |
| 88 | C1 c1; |
| 89 | C2 c2; |
Richard Smith | a523022 | 2015-03-27 01:37:43 +0000 | [diff] [blame] | 90 | D::X post_dx; |
Richard Smith | 9a71c99 | 2015-03-27 20:16:58 +0000 | [diff] [blame] | 91 | int post_use_dx = use_dx(post_dx); |
Richard Smith | d6aab59 | 2015-03-27 21:57:41 +0000 | [diff] [blame] | 92 | int post_e = E(0); |
| 93 | int post_ff = F<char>().f(); |
| 94 | int post_fg = F<char>().g<int>(); |
Richard Smith | 75ea855 | 2015-06-17 23:07:50 +0000 | [diff] [blame] | 95 | G::A post_ga = G::a; |
| 96 | decltype(G::h) post_gh = G::h; |
Richard Smith | c785276 | 2015-06-11 23:46:11 +0000 | [diff] [blame] | 97 | J<> post_j; |
| 98 | template<typename T, int N, template<typename> class K> struct J; |
| 99 | J<> post_j2; |
Richard Smith | 5293379 | 2015-06-16 21:57:05 +0000 | [diff] [blame] | 100 | FriendDefArg::Y<int> friend_def_arg; |
Richard Smith | afe800c | 2015-06-17 22:13:23 +0000 | [diff] [blame] | 101 | FriendDefArg::D<> friend_def_arg_d; |
Richard Smith | 529ecb2 | 2015-06-22 21:15:01 +0000 | [diff] [blame] | 102 | |
| 103 | #ifdef TEXTUAL |
| 104 | #include "use-defs.h" |
| 105 | void use_static_inline() { StaticInline::g({}); } |
| 106 | #endif |