summaryrefslogtreecommitdiff
path: root/gcc/testsuite/objc.dg/proto-hier-2.m
blob: 819cf4a5089b15b117580fa6e918dfa8a444f99b (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
/* Test protocol warning.  */
/* Contributed by Devang Patel <dpatel@apple.com>.  */
/* { dg-do compile } */

typedef struct objc_object { struct objc_class *class_pointer; } *id;

@protocol Bar
@end

id <Bar> Foo_Bar () { }

typedef struct
{
        int i;
} MyStruct;

@interface Foo
{
  id _mainData;
  MyStruct *_anotherData;
}

-(id) mainDataSource;
-(id) anotherDataSource;
-(id) my_method: (int) i;
@end

@implementation Foo
-(id) anotherDataSource
{
        return (id)_anotherData;
}

-(id) mainDataSource
{
        return _mainData;
}

-(id) my_method: (int) i
{
  id one = [self anotherDataSource];

  i = i - 1;
  // Do not issue warning about my_method not found in protocol
  return [(one ? [self mainDataSource] : one) my_method:i];
}

@end