blob: 7101e9604384d7a6b453bce4e04b3a29821c0030 [file] [log] [blame]
Chris Lattner42a997c2008-04-07 06:06:56 +00001// RUN: clang -fsyntax-only -pedantic -verify %s
Fariborz Jahanian4c71f1a2007-12-21 22:22:33 +00002
Fariborz Jahanian38860122008-01-09 00:33:05 +00003#define nil (void *)0;
4
Fariborz Jahanian4c71f1a2007-12-21 22:22:33 +00005extern void foo();
Fariborz Jahanian4c71f1a2007-12-21 22:22:33 +00006
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
21int main()
22{
23 id <MyProtocol> obj_id_p = nil;
24 MyClass *obj_c_cat_p = nil;
25 MyOtherClass *obj_c_super_p = nil;
Chris Lattner42a997c2008-04-07 06:06:56 +000026 MyOtherClass<MyProtocol> *obj_c_super_p_q = nil;
Fariborz Jahanian4c71f1a2007-12-21 22:22:33 +000027
Chris Lattner5cf216b2008-01-04 18:04:52 +000028 obj_c_cat_p = obj_id_p; // expected-error {{incompatible type assigning 'id<MyProtocol>', expected 'MyClass *'}}
29 obj_c_super_p = obj_id_p; // expected-error {{incompatible type assigning 'id<MyProtocol>', expected 'MyOtherClass *'}}
Fariborz Jahanian4c71f1a2007-12-21 22:22:33 +000030 obj_id_p = obj_c_cat_p; /* Ok */
31 obj_id_p = obj_c_super_p; /* Ok */
32
33 if (obj_c_cat_p == obj_id_p) foo(); /* Ok */
34 if (obj_c_super_p == obj_id_p) foo() ; /* Ok */
35 if (obj_id_p == obj_c_cat_p) foo(); /* Ok */
36 if (obj_id_p == obj_c_super_p) foo(); /* Ok */
37
Chris Lattner42a997c2008-04-07 06:06:56 +000038 obj_c_cat_p = obj_c_super_p; // ok.
39 obj_c_cat_p = obj_c_super_p_q; // ok.
40
Fariborz Jahanian4c71f1a2007-12-21 22:22:33 +000041 return 0;
42}