blob: 0accb46ac0efe6372e088dcc6b23a3c1b243e4f3 [file] [log] [blame]
Douglas Gregord6fb7ef2008-12-18 19:37:40 +00001// RUN: clang -fsyntax-only -verify %s
Douglas Gregordda78892008-12-18 23:43:31 +00002@interface Foo
3@end
4
5@implementation Foo
6
7void func(id);
8
9+ zone {
10 func(self);
11 return self;
12}
13
Douglas Gregor7ca09762008-11-27 01:19:21 +000014@protocol P0
15@end
16
17@protocol P1
18@end
19
20@interface A <P0>
Douglas Gregorcb7de522008-11-26 23:31:11 +000021@end
22
23@interface B : A
24@end
25
Douglas Gregor7ca09762008-11-27 01:19:21 +000026@interface C <P1>
27@end
28
Douglas Gregorcb7de522008-11-26 23:31:11 +000029int& f(A*);
30float& f(B*);
31void g(A*);
32
33int& h(A*);
34float& h(id);
35
36void test(A* a, B* b, id val) {
37 int& i1 = f(a);
38 float& f1 = f(b);
39 float& f2 = f(val);
40 g(a);
41 g(b);
42 g(val);
43 int& i2 = h(a);
44 float& f3 = h(val);
45 // int& i3 = h(b); FIXME: we match GCC here, but shouldn't this work?
46}
47
Douglas Gregor45920e82008-12-19 17:40:08 +000048void downcast_test(A* a) {
49 B* b = a; // expected-warning{{incompatible pointer types initializing 'B *', expected 'A *'}}
50 b = a; // expected-warning{{incompatible pointer types assigning 'B *', expected 'A *'}}
51}
52
Douglas Gregorcb7de522008-11-26 23:31:11 +000053int& cv(A*);
54float& cv(const A*);
55int& cv2(void*);
56float& cv2(const void*);
57
58void cv_test(A* a, B* b, const A* ac, const B* bc) {
59 int &i1 = cv(a);
60 int &i2 = cv(b);
61 float &f1 = cv(ac);
62 float &f2 = cv(bc);
63 int& i3 = cv2(a);
64 float& f3 = cv2(ac);
65}
Douglas Gregor7ca09762008-11-27 01:19:21 +000066
67
68int& qualid(id<P0>);
69float& qualid(id<P1>); // FIXME: GCC complains that this isn't an overload. Is it?
70
71void qualid_test(A *a, B *b, C *c) {
72 int& i1 = qualid(a);
73 int& i2 = qualid(b);
74 float& f1 = qualid(c);
75}