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 } */
6 /* One-line substitute for objc/objc.h */
7 typedef struct objc_object { struct objc_class *class_pointer; } *id;
9 typedef __UINTPTR_TYPE__ uintptr_t;
12 - (uintptr_t)someValue;
16 - (uintptr_t)anotherValue;
20 uintptr_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 .uintptr_t." } */
28 receiver += [receiver anotherValue]; /* { dg-warning "invalid receiver type .uintptr_t." } */
30 receiver += [(Obj *)receiver someValue]; /* { dg-warning ".Obj. may not respond to .\\-someValue." } */
31 /* { dg-error "invalid conversion" "" { 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-error "invalid conversion" "" { 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-error "invalid conversion" "" { target *-*-* } .-1 } */
47 receiver += [(Obj *)objrcvr2 anotherValue];
52 /* { dg-warning "messages without a matching method signature will be assumed to return .id. and accept .\.\.\.. as arguments" "" { target *-*-* } 0 } */