Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s |
Fariborz Jahanian | 4c71f1a | 2007-12-21 22:22:33 +0000 | [diff] [blame] | 2 | |
Fariborz Jahanian | 3886012 | 2008-01-09 00:33:05 +0000 | [diff] [blame] | 3 | #define nil (void *)0; |
| 4 | |
Fariborz Jahanian | 4c71f1a | 2007-12-21 22:22:33 +0000 | [diff] [blame] | 5 | extern void foo(); |
Fariborz Jahanian | 4c71f1a | 2007-12-21 22:22:33 +0000 | [diff] [blame] | 6 | |
| 7 | @protocol MyProtocol |
| 8 | - (void) method; |
| 9 | @end |
| 10 | |
| 11 | @interface MyClass |
| 12 | @end |
| 13 | |
| 14 | @interface MyClass (Addition) <MyProtocol> |
| 15 | - (void) method; |
| 16 | @end |
| 17 | |
| 18 | @interface MyOtherClass : MyClass |
| 19 | @end |
| 20 | |
| 21 | int main() |
| 22 | { |
| 23 | id <MyProtocol> obj_id_p = nil; |
| 24 | MyClass *obj_c_cat_p = nil; |
| 25 | MyOtherClass *obj_c_super_p = nil; |
Chris Lattner | 42a997c | 2008-04-07 06:06:56 +0000 | [diff] [blame] | 26 | MyOtherClass<MyProtocol> *obj_c_super_p_q = nil; |
Chris Lattner | b048981 | 2008-04-07 06:38:24 +0000 | [diff] [blame] | 27 | MyClass<MyProtocol> *obj_c_cat_p_q = nil; |
Fariborz Jahanian | 4c71f1a | 2007-12-21 22:22:33 +0000 | [diff] [blame] | 28 | |
Fariborz Jahanian | 192b146 | 2010-08-12 20:46:12 +0000 | [diff] [blame] | 29 | obj_c_cat_p = obj_id_p; |
| 30 | obj_c_super_p = obj_id_p; |
Fariborz Jahanian | 4c71f1a | 2007-12-21 22:22:33 +0000 | [diff] [blame] | 31 | obj_id_p = obj_c_cat_p; /* Ok */ |
| 32 | obj_id_p = obj_c_super_p; /* Ok */ |
| 33 | |
| 34 | if (obj_c_cat_p == obj_id_p) foo(); /* Ok */ |
| 35 | if (obj_c_super_p == obj_id_p) foo() ; /* Ok */ |
| 36 | if (obj_id_p == obj_c_cat_p) foo(); /* Ok */ |
| 37 | if (obj_id_p == obj_c_super_p) foo(); /* Ok */ |
| 38 | |
Chris Lattner | 42a997c | 2008-04-07 06:06:56 +0000 | [diff] [blame] | 39 | obj_c_cat_p = obj_c_super_p; // ok. |
| 40 | obj_c_cat_p = obj_c_super_p_q; // ok. |
Chris Lattner | b048981 | 2008-04-07 06:38:24 +0000 | [diff] [blame] | 41 | obj_c_super_p = obj_c_cat_p_q; // expected-warning {{incompatible pointer types}} |
| 42 | obj_c_cat_p_q = obj_c_super_p; |
Fariborz Jahanian | 4c71f1a | 2007-12-21 22:22:33 +0000 | [diff] [blame] | 43 | return 0; |
| 44 | } |