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