1 // RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
17 id <MyProtocol> obj_p = nil;
24 /* These should all generate errors. */
26 obj = i; // expected-error {{incompatible integer to pointer conversion assigning to 'id' from 'int'}}
27 obj = j; // expected-error {{incompatible pointer types assigning to 'id' from 'int *'}}
29 obj_p = i; // expected-error {{incompatible integer to pointer conversion assigning to 'id<MyProtocol>' from 'int'}}
30 obj_p = j; // expected-error {{incompatible pointer types assigning to 'id<MyProtocol>' from 'int *'}}
32 obj_c = i; // expected-error {{incompatible integer to pointer conversion assigning to 'MyClass *' from 'int'}}
33 obj_c = j; // expected-error {{incompatible pointer types assigning to 'MyClass *' from 'int *'}}
35 obj_C = i; // expected-error {{incompatible integer to pointer conversion assigning to 'Class' from 'int'}}
36 obj_C = j; // expected-error {{incompatible pointer types assigning to 'Class' from 'int *'}}
38 i = obj; // expected-error {{incompatible pointer to integer conversion assigning to 'int' from 'id'}}
39 i = obj_p; // expected-error {{incompatible pointer to integer conversion assigning to 'int' from 'id<MyProtocol>'}}
40 i = obj_c; // expected-error {{incompatible pointer to integer conversion assigning to 'int' from 'MyClass *'}}
41 i = obj_C; // expected-error {{incompatible pointer to integer conversion assigning to 'int' from 'Class'}}
43 j = obj; // expected-error {{incompatible pointer types assigning to 'int *' from 'id'}}
44 j = obj_p; // expected-error {{incompatible pointer types assigning to 'int *' from 'id<MyProtocol>'}}
45 j = obj_c; // expected-error {{incompatible pointer types assigning to 'int *' from 'MyClass *'}}
46 j = obj_C; // expected-error {{incompatible pointer types assigning to 'int *' from 'Class'}}
48 if (obj == i) foo() ; // expected-error {{comparison between pointer and integer ('id' and 'int')}}
49 if (i == obj) foo() ; // expected-error {{comparison between pointer and integer ('int' and 'id')}}
50 if (obj == j) foo() ; // expected-error {{comparison of distinct pointer types ('id' and 'int *')}}
51 if (j == obj) foo() ; // expected-error {{comparison of distinct pointer types ('int *' and 'id')}}
53 if (obj_c == i) foo() ; // expected-error {{comparison between pointer and integer ('MyClass *' and 'int')}}
54 if (i == obj_c) foo() ; // expected-error {{comparison between pointer and integer ('int' and 'MyClass *')}}
55 if (obj_c == j) foo() ; // expected-error {{comparison of distinct pointer types ('MyClass *' and 'int *')}}
56 if (j == obj_c) foo() ; // expected-error {{comparison of distinct pointer types ('int *' and 'MyClass *')}}
58 if (obj_p == i) foo() ; // expected-error {{comparison between pointer and integer ('id<MyProtocol>' and 'int')}}
59 if (i == obj_p) foo() ; // expected-error {{comparison between pointer and integer ('int' and 'id<MyProtocol>')}}
60 if (obj_p == j) foo() ; // expected-error {{comparison of distinct pointer types ('id<MyProtocol>' and 'int *')}}
61 if (j == obj_p) foo() ; // expected-error {{comparison of distinct pointer types ('int *' and 'id<MyProtocol>')}}
63 if (obj_C == i) foo() ; // expected-error {{comparison between pointer and integer ('Class' and 'int')}}
64 if (i == obj_C) foo() ; // expected-error {{comparison between pointer and integer ('int' and 'Class')}}
65 if (obj_C == j) foo() ; // expected-error {{comparison of distinct pointer types ('Class' and 'int *')}}
66 if (j == obj_C) foo() ; // expected-error {{comparison of distinct pointer types ('int *' and 'Class')}}
69 Class <MyProtocol> bar = nil;