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 } */ 5 6/* One-line substitute for objc/objc.h */ 7typedef struct objc_object { struct objc_class *class_pointer; } *id; 8 9@protocol Proto 10- (long)someValue; 11@end 12 13@interface Obj 14- (long)anotherValue; 15@end 16 17long foo(void) { 18 long receiver = 2; 19 Obj *objrcvr; 20 Obj <Proto> *objrcvr2; 21 22 /* NB: Since 'receiver' is an invalid ObjC message receiver, the compiler 23 should warn but then search for methods as if we were messaging 'id'. */ 24 25 receiver += [receiver someValue]; /* { dg-warning "invalid receiver type .long int." } */ 26 receiver += [receiver anotherValue]; /* { dg-warning "invalid receiver type .long int." } */ 27 28 receiver += [(Obj *)receiver someValue]; /* { dg-warning ".Obj. may not respond to .\\-someValue." } */ 29/* { dg-error "invalid conversion" "" { target *-*-* } .-1 } */ 30 31 receiver += [(Obj *)receiver anotherValue]; 32 receiver += [(Obj <Proto> *)receiver someValue]; 33 receiver += [(Obj <Proto> *)receiver anotherValue]; 34 receiver += [objrcvr someValue]; /* { dg-warning ".Obj. may not respond to .\\-someValue." } */ 35/* { dg-error "invalid conversion" "" { target *-*-* } .-1 } */ 36 37 receiver += [objrcvr anotherValue]; 38 receiver += [(Obj <Proto> *)objrcvr someValue]; 39 receiver += [(Obj <Proto> *)objrcvr anotherValue]; 40 receiver += [objrcvr2 someValue]; 41 receiver += [objrcvr2 anotherValue]; 42 receiver += [(Obj *)objrcvr2 someValue]; /* { dg-warning ".Obj. may not respond to .\\-someValue." } */ 43/* { dg-error "invalid conversion" "" { target *-*-* } .-1 } */ 44 45 receiver += [(Obj *)objrcvr2 anotherValue]; 46 47 return receiver; 48} 49 50/* { dg-warning "Messages without a matching method signature" "" { target *-*-* } 0 } */ 51/* { dg-warning "will be assumed to return .id. and accept" "" { target *-*-* } 0 } */ 52/* { dg-warning ".\.\.\.. as arguments" "" { target *-*-* } 0 } */ 53