| 1 |
/* Test for handling of protocol hierarchies. */ |
| 2 |
/* Author: Ziemowit Laski <[email protected]>. */ |
| 3 |
/* { dg-do compile } */ |
| 4 |
/* { dg-additional-options "-Wno-objc-root-class" } */ |
| 5 |
|
| 6 |
/* One-line substitute for objc/objc.h */ |
| 7 |
typedef struct objc_object { struct objc_class *class_pointer; } *id; |
| 8 |
|
| 9 |
@protocol NSObj |
| 10 |
- (void)someMethod; |
| 11 |
@end |
| 12 |
|
| 13 |
@protocol NSCopying |
| 14 |
- (void)someOtherMethod; |
| 15 |
@end |
| 16 |
|
| 17 |
@interface NSObject <NSObj> |
| 18 |
- (void)someMethod; |
| 19 |
@end |
| 20 |
|
| 21 |
@implementation NSObject |
| 22 |
- (void)someMethod {} |
| 23 |
@end |
| 24 |
|
| 25 |
@protocol Booing <NSObj> |
| 26 |
- (void)boo; |
| 27 |
@end |
| 28 |
|
| 29 |
@interface Boo: NSObject <Booing> // protocol has only one parent |
| 30 |
@end |
| 31 |
|
| 32 |
@implementation Boo |
| 33 |
- (void)boo {} |
| 34 |
@end |
| 35 |
|
| 36 |
@protocol Fooing <NSCopying, NSObj> // Fooing has two parent protocols |
| 37 |
- (void)foo; |
| 38 |
@end |
| 39 |
|
| 40 |
@interface Foo: NSObject <Fooing> |
| 41 |
@end |
| 42 |
|
| 43 |
@implementation Foo |
| 44 |
- (void)foo {} |
| 45 |
- (void)someOtherMethod {} |
| 46 |
@end |
| 47 |
|
| 48 |
int foo(void) { |
| 49 |
id<Booing, Fooing> stupidVar; |
| 50 |
[stupidVar boo]; |
| 51 |
[stupidVar foo]; |
| 52 |
[stupidVar anotherMsg]; /* { dg-warning ".\\-anotherMsg. not found in protocol" } */ |
| 53 |
/* { dg-warning "no .\\-anotherMsg. method found" "" { target *-*-* } .-1 } */ |
| 54 |
return 0; |
| 55 |
} |
| 56 |
|
| 57 |
/* { dg-warning "messages without a matching method signature will be assumed to return .id. and accept .\.\.\.. as arguments" "" { target *-*-* } 0 } */ |