Keep the source location of the selector in ObjCMessageExpr.
[clang.git] / test / SemaObjC / comptypes-3.m
blob6c1ce419b621e562bad311b38e559cea76cd45ae
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 #define nil (void *)0;
5 extern void foo();
7 @protocol MyProtocolA
8 - (void) methodA;
9 @end
11 @protocol MyProtocolB
12 - (void) methodB;
13 @end
15 @protocol MyProtocolAB <MyProtocolA, MyProtocolB>
16 @end
18 @protocol MyProtocolAC <MyProtocolA>
19 - (void) methodC;
20 @end
22 int main()
24   id<MyProtocolA> obj_a = nil;
25   id<MyProtocolB> obj_b = nil;
26   id<MyProtocolAB> obj_ab = nil;
27   id<MyProtocolAC> obj_ac = nil;
29   obj_a = obj_b;  // expected-warning {{assigning to 'id<MyProtocolA>' from incompatible type 'id<MyProtocolB>'}}
30   obj_a = obj_ab; /* Ok */
31   obj_a = obj_ac; /* Ok */
32   
33   obj_b = obj_a;  // expected-warning {{assigning to 'id<MyProtocolB>' from incompatible type 'id<MyProtocolA>'}}
34   obj_b = obj_ab; /* Ok */
35   obj_b = obj_ac; // expected-warning {{assigning to 'id<MyProtocolB>' from incompatible type 'id<MyProtocolAC>'}}
36   
37   obj_ab = obj_a;  // expected-warning {{assigning to 'id<MyProtocolAB>' from incompatible type 'id<MyProtocolA>'}}
38   obj_ab = obj_b;  // expected-warning {{assigning to 'id<MyProtocolAB>' from incompatible type 'id<MyProtocolB>'}}
39   obj_ab = obj_ac; // expected-warning {{assigning to 'id<MyProtocolAB>' from incompatible type 'id<MyProtocolAC>'}}
40   
41   obj_ac = obj_a;  // expected-warning {{assigning to 'id<MyProtocolAC>' from incompatible type 'id<MyProtocolA>'}}
42   obj_ac = obj_b;  // expected-warning {{assigning to 'id<MyProtocolAC>' from incompatible type 'id<MyProtocolB>'}}
43   obj_ac = obj_ab; // expected-warning {{assigning to 'id<MyProtocolAC>' from incompatible type 'id<MyProtocolAB>'}}
45   if (obj_a == obj_b) foo (); // expected-warning {{comparison of distinct pointer types ('id<MyProtocolA>' and 'id<MyProtocolB>')}}
46   if (obj_b == obj_a) foo (); // expected-warning {{comparison of distinct pointer types ('id<MyProtocolB>' and 'id<MyProtocolA>')}}
48   if (obj_a == obj_ab) foo (); /* Ok */
49   if (obj_ab == obj_a) foo (); /* Ok */ 
51   if (obj_a == obj_ac) foo (); /* Ok */ 
52   if (obj_ac == obj_a) foo (); /* Ok */ 
54   if (obj_b == obj_ab) foo (); /* Ok */ 
55   if (obj_ab == obj_b) foo (); /* Ok */ 
57   if (obj_b == obj_ac) foo (); // expected-warning {{comparison of distinct pointer types ('id<MyProtocolB>' and 'id<MyProtocolAC>')}} 
58   if (obj_ac == obj_b) foo (); // expected-warning {{comparison of distinct pointer types ('id<MyProtocolAC>' and 'id<MyProtocolB>')}} 
60   if (obj_ab == obj_ac) foo (); // expected-warning {{comparison of distinct pointer types ('id<MyProtocolAB>' and 'id<MyProtocolAC>')}} 
61   if (obj_ac == obj_ab) foo (); // expected-warning {{comparison of distinct pointer types ('id<MyProtocolAC>' and 'id<MyProtocolAB>')}} 
63   return 0;