1 // RUN: %clang_cc1 -fsyntax-only -verify %s
15 @protocol MyProtocolAB <MyProtocolA, MyProtocolB>
18 @protocol MyProtocolAC <MyProtocolA>
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 */
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>'}}
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>'}}
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>')}}