URL
https://opencores.org/ocsvn/scarts/scarts/trunk
Details |
Compare with Previous |
View Log
Line No. |
Rev |
Author |
Line |
1 |
12 |
jlechner |
/* Test for situations in which protocol conformance information
|
2 |
|
|
may be lost while casting. */
|
3 |
|
|
/* Author: Ziemowit Laski . */
|
4 |
|
|
/* { dg-do compile } */
|
5 |
|
|
|
6 |
|
|
/* One-line substitute for objc/objc.h */
|
7 |
|
|
typedef 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 |
|
|
|
17 |
|
|
long foo(void) {
|
18 |
|
|
long receiver = 2;
|
19 |
|
|
Obj *objrcvr;
|
20 |
|
|
Obj *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 *-*-* } 28 } */
|
30 |
|
|
|
31 |
|
|
receiver += [(Obj *)receiver anotherValue];
|
32 |
|
|
receiver += [(Obj *)receiver someValue];
|
33 |
|
|
receiver += [(Obj *)receiver anotherValue];
|
34 |
|
|
receiver += [objrcvr someValue]; /* { dg-warning ".Obj. may not respond to .\\-someValue." } */
|
35 |
|
|
/* { dg-error "invalid conversion" "" { target *-*-* } 34 } */
|
36 |
|
|
|
37 |
|
|
receiver += [objrcvr anotherValue];
|
38 |
|
|
receiver += [(Obj *)objrcvr someValue];
|
39 |
|
|
receiver += [(Obj *)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-warning "invalid conversion" "" { target *-*-* } 42 } */
|
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 } */
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.