1 /* Test warnings for assignments and comparisons between ObjC and C types. */
2 /* Author: Nicola Pero <nicola@brainstorm.co.uk>. */
3 /* { dg-do compile } */
6 /* The NeXT runtime headers do not define NULL. */
8 #define NULL ((void *)0)
21 id <MyProtocol> obj_p = nil;
28 /* These should all generate warnings. */
30 obj = i; /* { dg-warning "pointer from integer without a cast" } */
31 obj = j; /* { dg-warning "incompatible pointer type" } */
33 obj_p = i; /* { dg-warning "pointer from integer without a cast" } */
34 obj_p = j; /* { dg-warning "incompatible pointer type" } */
36 obj_c = i; /* { dg-warning "pointer from integer without a cast" } */
37 obj_c = j; /* { dg-warning "incompatible pointer type" } */
39 obj_C = i; /* { dg-warning "pointer from integer without a cast" } */
40 obj_C = j; /* { dg-warning "incompatible pointer type" } */
42 i = obj; /* { dg-warning "integer from pointer without a cast" } */
43 i = obj_p; /* { dg-warning "integer from pointer without a cast" } */
44 i = obj_c; /* { dg-warning "integer from pointer without a cast" } */
45 i = obj_C; /* { dg-warning "integer from pointer without a cast" } */
47 j = obj; /* { dg-warning "incompatible pointer type" } */
48 j = obj_p; /* { dg-warning "incompatible pointer type" } */
49 j = obj_c; /* { dg-warning "incompatible pointer type" } */
50 j = obj_C; /* { dg-warning "incompatible pointer type" } */
52 if (obj == i) ; /* { dg-warning "comparison between pointer and integer" } */
53 if (i == obj) ; /* { dg-warning "comparison between pointer and integer" } */
54 if (obj == j) ; /* { dg-warning "lacks a cast" } */
55 if (j == obj) ; /* { dg-warning "lacks a cast" } */
57 if (obj_c == i) ; /*{ dg-warning "comparison between pointer and integer" }*/
58 if (i == obj_c) ; /*{ dg-warning "comparison between pointer and integer" }*/
59 if (obj_c == j) ; /* { dg-warning "lacks a cast" } */
60 if (j == obj_c) ; /* { dg-warning "lacks a cast" } */
62 if (obj_p == i) ; /*{ dg-warning "comparison between pointer and integer" }*/
63 if (i == obj_p) ; /*{ dg-warning "comparison between pointer and integer" }*/
64 if (obj_p == j) ; /* { dg-warning "lacks a cast" } */
65 if (j == obj_p) ; /* { dg-warning "lacks a cast" } */
67 if (obj_C == i) ; /*{ dg-warning "comparison between pointer and integer" }*/
68 if (i == obj_C) ; /*{ dg-warning "comparison between pointer and integer" }*/
69 if (obj_C == j) ; /* { dg-warning "lacks a cast" } */
70 if (j == obj_C) ; /* { dg-warning "lacks a cast" } */