1 /* Test for situations in which protocol conformance information
2 may be lost while casting. */
3 /* Author: Ziemowit Laski <zlaski@apple.com>. */
4 /* { dg-do compile } */
8 /* One-line substitute for objc/objc.h */
9 typedef struct objc_object { struct objc_class *class_pointer; } *id;
12 - (intptr_t)someValue;
16 - (intptr_t)anotherValue;
20 intptr_t receiver = 2;
22 Obj <Proto> *objrcvr2;
24 /* NB: Since 'receiver' is an invalid ObjC message receiver, the compiler
25 should warn but then search for methods as if we were messaging 'id'. */
27 receiver += [receiver someValue]; /* { dg-warning "invalid receiver type .intptr_t." } */
28 receiver += [receiver anotherValue]; /* { dg-warning "invalid receiver type .intptr_t." } */
30 receiver += [(Obj *)receiver someValue]; /* { dg-warning ".Obj. may not respond to .\\-someValue." } */
31 /* { dg-warning "assignment to 'intptr_t' {aka '(long )?int'} from 'id' makes integer from pointer without a cast" "" { target *-*-* } .-1 } */
33 receiver += [(Obj *)receiver anotherValue];
34 receiver += [(Obj <Proto> *)receiver someValue];
35 receiver += [(Obj <Proto> *)receiver anotherValue];
36 receiver += [objrcvr someValue]; /* { dg-warning ".Obj. may not respond to .\\-someValue." } */
37 /* { dg-warning "assignment to 'intptr_t' {aka '(long )?int'} from 'id' makes integer from pointer without a cast" "" { target *-*-* } .-1 } */
39 receiver += [objrcvr anotherValue];
40 receiver += [(Obj <Proto> *)objrcvr someValue];
41 receiver += [(Obj <Proto> *)objrcvr anotherValue];
42 receiver += [objrcvr2 someValue];
43 receiver += [objrcvr2 anotherValue];
44 receiver += [(Obj *)objrcvr2 someValue]; /* { dg-warning ".Obj. may not respond to .\\-someValue." } */
45 /* { dg-warning "assignment to 'intptr_t' {aka '(long )?int'} from 'id' makes integer from pointer without a cast" "" { target *-*-* } .-1 } */
47 receiver += [(Obj *)objrcvr2 anotherValue];
52 /* { dg-warning "Messages without a matching method signature" "" { target *-*-* } 0 } */
53 /* { dg-warning "will be assumed to return .id. and accept" "" { target *-*-* } 0 } */
54 /* { dg-warning ".\.\.\.. as arguments" "" { target *-*-* } 0 } */