| 1 |
704 |
jeremybenn |
/* 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 |
|
|
#include <stdint.h>
|
| 7 |
|
|
|
| 8 |
|
|
/* One-line substitute for objc/objc.h */
|
| 9 |
|
|
typedef struct objc_object { struct objc_class *class_pointer; } *id;
|
| 10 |
|
|
|
| 11 |
|
|
@protocol Proto
|
| 12 |
|
|
- (intptr_t)someValue;
|
| 13 |
|
|
@end
|
| 14 |
|
|
|
| 15 |
|
|
@interface Obj
|
| 16 |
|
|
- (intptr_t)anotherValue;
|
| 17 |
|
|
@end
|
| 18 |
|
|
|
| 19 |
|
|
long foo(void) {
|
| 20 |
|
|
intptr_t receiver = 2;
|
| 21 |
|
|
Obj *objrcvr;
|
| 22 |
|
|
Obj <Proto> *objrcvr2;
|
| 23 |
|
|
|
| 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'. */
|
| 26 |
|
|
|
| 27 |
|
|
receiver += [receiver someValue]; /* { dg-warning "invalid receiver type .intptr_t." } */
|
| 28 |
|
|
receiver += [receiver anotherValue]; /* { dg-warning "invalid receiver type .intptr_t." } */
|
| 29 |
|
|
|
| 30 |
|
|
receiver += [(Obj *)receiver someValue]; /* { dg-warning ".Obj. may not respond to .\\-someValue." } */
|
| 31 |
|
|
/* { dg-warning "assignment makes integer from pointer without a cast" "" { target *-*-* } 30 } */
|
| 32 |
|
|
|
| 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 makes integer from pointer without a cast" "" { target *-*-* } 36 } */
|
| 38 |
|
|
|
| 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 makes integer from pointer without a cast" "" { target *-*-* } 44 } */
|
| 46 |
|
|
|
| 47 |
|
|
receiver += [(Obj *)objrcvr2 anotherValue];
|
| 48 |
|
|
|
| 49 |
|
|
return receiver;
|
| 50 |
|
|
}
|
| 51 |
|
|
|
| 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 } */
|