1 // RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
17 id <MyProtocol> obj_p = nil;
24 /* The incompatible pointer types should all generate warnings, while the
25 incompatible integer to/from pointer conversions default to an error. */
27 obj = i; // expected-error {{incompatible integer to pointer conversion assigning to 'id' from 'int'}}
28 obj = j; // expected-warning {{incompatible pointer types assigning to 'id' from 'int *'}}
30 obj_p = i; // expected-error {{incompatible integer to pointer conversion assigning to 'id<MyProtocol>' from 'int'}}
31 obj_p = j; // expected-warning {{incompatible pointer types assigning to 'id<MyProtocol>' from 'int *'}}
33 obj_c = i; // expected-error {{incompatible integer to pointer conversion assigning to 'MyClass *' from 'int'}}
34 obj_c = j; // expected-warning {{incompatible pointer types assigning to 'MyClass *' from 'int *'}}
36 obj_C = i; // expected-error {{incompatible integer to pointer conversion assigning to 'Class' from 'int'}}
37 obj_C = j; // expected-warning {{incompatible pointer types assigning to 'Class' from 'int *'}}
39 i = obj; // expected-error {{incompatible pointer to integer conversion assigning to 'int' from 'id'}}
40 i = obj_p; // expected-error {{incompatible pointer to integer conversion assigning to 'int' from 'id<MyProtocol>'}}
41 i = obj_c; // expected-error {{incompatible pointer to integer conversion assigning to 'int' from 'MyClass *'}}
42 i = obj_C; // expected-error {{incompatible pointer to integer conversion assigning to 'int' from 'Class'}}
44 j = obj; // expected-warning {{incompatible pointer types assigning to 'int *' from 'id'}}
45 j = obj_p; // expected-warning {{incompatible pointer types assigning to 'int *' from 'id<MyProtocol>'}}
46 j = obj_c; // expected-warning {{incompatible pointer types assigning to 'int *' from 'MyClass *'}}
47 j = obj_C; // expected-warning {{incompatible pointer types assigning to 'int *' from 'Class'}}
49 if (obj == i) foo() ; // expected-warning {{comparison between pointer and integer ('id' and 'int')}}
50 if (i == obj) foo() ; // expected-warning {{comparison between pointer and integer ('int' and 'id')}}
51 if (obj == j) foo() ; // expected-warning {{comparison of distinct pointer types ('id' and 'int *')}}
52 if (j == obj) foo() ; // expected-warning {{comparison of distinct pointer types ('int *' and 'id')}}
54 if (obj_c == i) foo() ; // expected-warning {{comparison between pointer and integer ('MyClass *' and 'int')}}
55 if (i == obj_c) foo() ; // expected-warning {{comparison between pointer and integer ('int' and 'MyClass *')}}
56 if (obj_c == j) foo() ; // expected-warning {{comparison of distinct pointer types ('MyClass *' and 'int *')}}
57 if (j == obj_c) foo() ; // expected-warning {{comparison of distinct pointer types ('int *' and 'MyClass *')}}
59 if (obj_p == i) foo() ; // expected-warning {{comparison between pointer and integer ('id<MyProtocol>' and 'int')}}
60 if (i == obj_p) foo() ; // expected-warning {{comparison between pointer and integer ('int' and 'id<MyProtocol>')}}
61 if (obj_p == j) foo() ; // expected-warning {{comparison of distinct pointer types ('id<MyProtocol>' and 'int *')}}
62 if (j == obj_p) foo() ; // expected-warning {{comparison of distinct pointer types ('int *' and 'id<MyProtocol>')}}
64 if (obj_C == i) foo() ; // expected-warning {{comparison between pointer and integer ('Class' and 'int')}}
65 if (i == obj_C) foo() ; // expected-warning {{comparison between pointer and integer ('int' and 'Class')}}
66 if (obj_C == j) foo() ; // expected-warning {{comparison of distinct pointer types ('Class' and 'int *')}}
67 if (j == obj_C) foo() ; // expected-warning {{comparison of distinct pointer types ('int *' and 'Class')}}
70 Class <MyProtocol> bar = nil;