OSDN Git Service

ba832840062c3e2f366f75ce900036767f0dd855
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / objc.dg / method-9.m
1 /* Check if finding multiple signatures for a method is handled gracefully
2    when method lookup succeeds (see also method-7.m).  */
3 /* Contributed by Ziemowit Laski <zlaski@apple.com>  */
4 /* { dg-do compile } */
5
6 #include <objc/Object.h>
7
8 @protocol MyObject
9 - (id)initWithData:(Object *)data;
10 @end
11
12 @protocol SomeOther
13 - (id)initWithData:(int)data;
14 @end
15
16 @protocol MyCoding
17 - (id)initWithData:(id<MyObject, MyCoding>)data;
18 @end
19
20 @interface NTGridDataObject: Object <MyCoding>
21 {
22     Object<MyCoding> *_data;
23 }
24 + (NTGridDataObject*)dataObject:(id<MyObject, MyCoding>)data;
25 @end
26
27 @implementation NTGridDataObject
28 - (id)initWithData:(id<MyObject, MyCoding>)data {
29   return data;
30 }
31 + (NTGridDataObject*)dataObject:(id<MyObject, MyCoding>)data
32 {
33     NTGridDataObject *result = [[NTGridDataObject alloc] initWithData:data];
34      /* { dg-warning "multiple methods named .\\-initWithData:. found" "" { target *-*-* } 33 } */
35      /* { dg-warning "using .\\-\\(id\\)initWithData:\\(Object \\*\\)data." "" { target *-*-* } 9 } */
36      /* { dg-warning "also found .\\-\\(id\\)initWithData:\\(id <MyObject, MyCoding>\\)data." "" { target *-*-* } 17 } */
37      /* { dg-warning "also found .\\-\\(id\\)initWithData:\\(int\\)data." "" { target *-*-* } 13 } */
38
39      /* The following warning is a consequence of picking the "wrong" method signature.  */
40      /* { dg-warning "passing arg 1 of .initWithData:. from incompatible pointer type" "" { target *-*-* } 33 } */
41     return result;
42 }
43 @end