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
9 // Trigger import of definitions, but don't make them visible.
11 #ifdef EARLY_INDIRECT_INCLUDE
13 // expected-warning@defs.h:28 3{{anonymous non-C-compatible type}}
14 // expected-note@defs.h:28 6{{type is}}
18 // expected-error-re@-1 {{missing '#include "{{.*}}-defs.h"'; 'A' must be declared}}
19 // expected-note@defs.h:1 +{{here}}
20 extern class A pre_a2
;
21 int pre_use_a
= use_a(pre_a2
); // expected-error 2{{'A' must be defined}} expected-error {{'use_a' must be declared}}
22 // expected-note@defs.h:2 +{{here}}
24 B::Inner2 pre_bi
; // expected-error +{{must be declared}} expected-error +{{must be defined}}
25 // expected-note@defs.h:4 +{{here}}
26 // expected-note@defs.h:17 +{{here}}
27 void pre_bfi(B b
) { // expected-error +{{must be declared}}
31 C_Base
<1> pre_cb1
; // expected-error +{{must be declared}} expected-error +{{must be defined}}
32 // expected-note@defs.h:23 +{{here}}
33 C1 pre_c1
; // expected-error +{{must be declared}}
34 // expected-note@defs.h:25 +{{here}}
35 C2 pre_c2
; // expected-error +{{must be declared}}
36 // expected-note@defs.h:26 +{{here}}
38 D::X pre_dx
; // expected-error +{{must be declared}} expected-error +{{must be defined}}
39 // expected-note@defs.h:28 +{{here}}
40 // expected-note@defs.h:29 +{{here}}
41 int pre_use_dx
= use_dx(pre_dx
); // ignored; pre_dx is invalid
43 int pre_e
= E(0); // expected-error {{must be declared}}
44 // expected-note@defs.h:32 +{{here}}
46 int pre_ff
= F
<int>().f(); // expected-error +{{must be declared}}
47 int pre_fg
= F
<int>().g
<int>(); // expected-error +{{must be declared}}
48 // expected-note@defs.h:34 +{{here}}
50 G::A pre_ga
// expected-error +{{must be declared}}
51 = G::a
; // expected-error +{{must be declared}}
52 // expected-note@defs.h:50 +{{here}}
53 decltype(G::h
) pre_gh
= G::h
; // expected-error +{{must be declared}} expected-error +{{must be defined}}
54 // expected-note@defs.h:51 +{{here}}
56 int pre_h
= H(); // expected-error +{{must be declared}}
57 // expected-note@defs.h:56 +{{here}}
58 using pre_i
= I
<>; // expected-error +{{must be declared}} expected-error +{{default argument of 'I' must be defined}}
59 // expected-note@defs.h:57 +{{here}}
61 J
<> pre_j
; // expected-error {{'J' must be declared}}
62 // expected-error-re@-1 {{missing '#include "{{.*}}.h"'; default argument of 'J' must be defined before it is used}}
63 // expected-note@defs.h:58 +{{here}}
65 ScopedEnum pre_scopedenum
; // expected-error {{must be declared}}
66 // expected-note@defs.h:105 0-1{{here}}
67 // expected-note@defs.h:106 0-1{{here}}
68 enum ScopedEnum
: int;
69 ScopedEnum pre_scopedenum_declared
; // ok
71 // Make definitions from second module visible.
73 #include "import-and-redefine.h"
74 #elif defined IMPORT_USE_2
75 #include "use-defs-2.h"
77 #include "merged-defs.h"
81 int post_use_a
= use_a(post_a
);
90 int post_use_dx
= use_dx(post_dx
);
92 int post_ff
= F
<char>().f();
93 int post_fg
= F
<char>().g
<int>();
95 decltype(G::h
) post_gh
= G::h
;
99 template<typename T
, int N
, template<typename
> class K
> struct J
;
101 FriendDefArg::Y
<int> friend_def_arg
;
102 FriendDefArg::D
<> friend_def_arg_d
;
103 int post_anon_x_n
= Anon::X().n
;
105 MergeFunctionTemplateSpecializations::X
<int>::Q
<char> xiqc
;
108 #include "use-defs.h"
109 void use_static_inline() { StaticInline::g({}); }
110 #ifdef EARLY_INDIRECT_INCLUDE
111 // expected-warning@-2 {{ambiguous use of internal linkage declaration 'g' defined in multiple modules}}
112 // expected-note@defs.h:71 {{declared here in module 'redef'}}
113 // expected-note@defs.h:71 {{declared here in module 'stuff.use'}}
115 int use_anon_enum
= G::g
;
116 #ifdef EARLY_INDIRECT_INCLUDE
117 // expected-warning@-2 3{{ambiguous use of internal linkage declaration 'g' defined in multiple modules}}
118 // FIXME: These notes are produced, but -verify can't match them?
119 // FIXME-note@defs.h:51 3{{declared here in module 'redef'}}
120 // FIXME-note@defs.h:51 3{{declared here in module 'stuff.use'}}
122 int use_named_enum
= G::i
;