1/* Test for handling of protocol hierarchies.  */
2/* Author: Ziemowit Laski <zlaski@apple.com>.  */
3/* { dg-do compile } */
4
5/* One-line substitute for objc/objc.h */
6typedef struct objc_object { struct objc_class *class_pointer; } *id;
7
8@protocol NSObj
9- (void)someMethod;
10@end
11
12@protocol NSCopying
13- (void)someOtherMethod;
14@end
15
16@interface NSObject <NSObj>
17- (void)someMethod;
18@end
19
20@implementation NSObject
21- (void)someMethod {}
22@end
23
24@protocol Booing <NSObj>
25- (void)boo;
26@end
27
28@interface Boo: NSObject <Booing>  // protocol has only one parent
29@end
30
31@implementation Boo
32- (void)boo {}
33@end
34
35@protocol Fooing <NSCopying, NSObj>  // Fooing has two parent protocols
36- (void)foo;
37@end
38
39@interface Foo: NSObject <Fooing>
40@end
41
42@implementation Foo
43- (void)foo {}
44- (void)someOtherMethod {}
45@end
46
47int foo(void) {
48  id<Booing, Fooing> stupidVar;
49  [stupidVar boo];
50  [stupidVar foo];
51  [stupidVar anotherMsg]; /* { dg-warning "not implemented by protocol" } */
52  /* { dg-warning "return type defaults to id" "" { target *-*-* } 51 } */
53  return 0;
54}
55