1// RUN: rm -rf %t 2// RUN: %clang_cc1 -fmodules -Wreturn-type -fmodules-cache-path=%t -I %S/Inputs %s -verify -Wno-objc-root-class 3 4@class C2; 5@class C3; 6@class C3; 7@import redecl_merge_left; 8typedef struct my_struct_type *my_struct_ref; 9@protocol P4; 10@class C3; 11@class C3; 12 13int *call_eventually_noreturn(void) { 14 eventually_noreturn(); 15} // expected-warning{{control reaches end of non-void function}} 16 17int *call_eventually_noreturn2(void) { 18 eventually_noreturn2(); 19} // expected-warning{{control reaches end of non-void function}} 20 21@import redecl_merge_right; 22 23int *call_eventually_noreturn_again(void) { 24 eventually_noreturn(); 25} 26 27int *call_eventually_noreturn2_again(void) { 28 // noreturn and non-noreturn functions have different types 29 eventually_noreturn2(); // expected-error{{call to 'eventually_noreturn2' is ambiguous}} 30 // expected-note@93{{candidate function}} 31 // expected-note@90{{candidate function}} 32} 33 34@implementation A 35- (Super*)init { return self; } 36@end 37 38void f(A *a) { 39 [a init]; 40} 41 42@class A; 43 44B *f1() { 45 return [B create_a_B]; 46} 47 48@class B; 49 50void testProtoMerge(id<P1> p1, id<P2> p2) { 51 [p1 protoMethod1]; 52 [p2 protoMethod2]; 53} 54 55struct S1 { 56 int s1_field; 57}; 58 59struct S3 { 60 int s3_field; 61}; 62 63void testTagMerge() { 64 consume_S1(produce_S1()); 65 struct S2 s2; 66 s2.field = 0; 67 consume_S2(produce_S2()); 68 struct S1 s1; 69 s1.s1_field = 0; 70 consume_S3(produce_S3()); 71 struct S4 s4; 72 s4.field = 0; 73 consume_S4(produce_S4()); 74 struct S3 s3; 75 s3.s3_field = 0; 76} 77 78void testTypedefMerge(int i, double d) { 79 T1 *ip = &i; 80 // FIXME: Typedefs aren't actually merged in the sense of other merges, because 81 // we should only merge them when the types are identical. 82 // in other file: expected-note@60{{candidate found by name lookup is 'T2'}} 83 // in other file: expected-note@63{{candidate found by name lookup is 'T2'}} 84 T2 *dp = &d; // expected-error{{reference to 'T2' is ambiguous}} 85} 86 87void testFuncMerge(int i) { 88 func0(i); 89 func1(i); 90 // in other file: expected-note@64{{candidate function}} 91 // in other file: expected-note@70{{candidate function}} 92 func2(i); // expected-error{{call to 'func2' is ambiguous}} 93} 94 95void testVarMerge(int i) { 96 var1 = i; 97 // in other files: expected-note@77 2{{candidate found by name lookup is 'var2'}} 98 var2 = i; // expected-error{{reference to 'var2' is ambiguous}} 99 // in other files: expected-note@79 2{{candidate found by name lookup is 'var3'}} 100 var3 = i; // expected-error{{reference to 'var3' is ambiguous}} 101} 102 103// Test redeclarations of entities in explicit submodules, to make 104// sure we're maintaining the declaration chains even when normal name 105// lookup can't see what we're looking for. 106void testExplicit() { 107 Explicit *e; 108 int *(*fp)(void) = &explicit_func; 109 int *ip = explicit_func(); 110 111 // FIXME: Should complain about definition not having been imported. 112 struct explicit_struct es = { 0 }; 113} 114 115// Test resolution of declarations from multiple modules with no 116// common original declaration. 117void test_C(C *c) { 118 c = get_a_C(); 119 accept_a_C(c); 120} 121 122void test_C2(C2 *c2) { 123 c2 = get_a_C2(); 124 accept_a_C2(c2); 125} 126 127void test_C3(C3 *c3) { 128 c3 = get_a_C3(); 129 accept_a_C3(c3); 130} 131 132C4 *global_C4; 133 134ClassWithDef *cwd1; 135 136@import redecl_merge_left_left; 137 138void test_C4a(C4 *c4) { 139 global_C4 = c4 = get_a_C4(); 140 accept_a_C4(c4); 141} 142 143void test_ClassWithDef(ClassWithDef *cwd) { 144 [cwd method]; 145} 146 147@import redecl_merge_bottom; 148 149void test_C4b() { 150 if (&refers_to_C4) { 151 } 152} 153 154@implementation B 155+ (B*)create_a_B { return 0; } 156@end 157 158void g(A *a) { 159 [a init]; 160} 161 162@protocol P3 163- (void)p3_method; 164@end 165 166id<P4> p4; 167id<P3> p3; 168 169// Make sure we don't get conflicts with 'id'. 170funcptr_with_id fid; 171id id_global; 172 173 174