summaryrefslogtreecommitdiff
path: root/gcc/testsuite/objc.dg/proto-hier-1.m
blob: 99dcbc567737d276d16b1f0f92a9ccc1e3671bc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* Test for handling of protocol hierarchies.  */
/* Author: Ziemowit Laski <zlaski@apple.com>.  */
/* { dg-do compile } */

/* One-line substitute for objc/objc.h */
typedef struct objc_object { struct objc_class *class_pointer; } *id;

@protocol NSObj 
- (void)someMethod;
@end

@protocol NSCopying 
- (void)someOtherMethod;
@end

@interface NSObject <NSObj>
- (void)someMethod; 
@end

@implementation NSObject
- (void)someMethod {}
@end

@protocol Booing <NSObj>
- (void)boo;
@end

@interface Boo: NSObject <Booing>  // protocol has only one parent
@end

@implementation Boo
- (void)boo {}
@end

@protocol Fooing <NSCopying, NSObj>  // Fooing has two parent protocols
- (void)foo;
@end

@interface Foo: NSObject <Fooing>
@end

@implementation Foo
- (void)foo {}
- (void)someOtherMethod {}
@end

int foo(void) {
  id<Booing, Fooing> stupidVar;
  [stupidVar boo];
  [stupidVar foo];
  [stupidVar anotherMsg]; /* { dg-warning ".\\-anotherMsg. not found in protocol" } */
       /* { dg-warning "no .\\-anotherMsg. method found" "" { target *-*-* } 51 } */
  return 0;
}

/* { dg-warning "Messages without a matching method signature" "" { target *-*-* } 0 } */
/* { dg-warning "will be assumed to return .id. and accept" "" { target *-*-* } 0 } */
/* { dg-warning ".\.\.\.. as arguments" "" { target *-*-* } 0 } */