Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / objc.dg / method-9.m
blobade5d64e71a33099d0f98bc5a0f4bc7b2d0a2dfc
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>  */
5 /* { dg-do compile } */
6 /* { dg-options "-Wstrict-selector-match" } */
8 #include <objc/Object.h>
10 @protocol MyObject
11 - (id)initWithData:(Object *)data;
12 @end
14 @protocol SomeOther
15 - (id)initWithData:(int)data;
16 @end
18 @protocol MyCoding
19 - (id)initWithData:(id<MyObject, MyCoding>)data;
20 @end
22 @interface NTGridDataObject: Object <MyCoding>
24     Object<MyCoding> *_data;
26 + (NTGridDataObject*)dataObject:(id<MyObject, MyCoding>)data;
27 @end
29 @implementation NTGridDataObject
30 - (id)initWithData:(id<MyObject, MyCoding>)data {
31   return data;
33 + (NTGridDataObject*)dataObject:(id<MyObject, MyCoding>)data
35     NTGridDataObject *result = [[NTGridDataObject alloc] initWithData:data];
36     /* { dg-warning "multiple methods named .\\-initWithData:. found" "" { target *-*-* } 35 } */
37     /* { dg-warning "using .\\-\\(id\\)initWithData:\\(Object \\*\\)data." "" { target *-*-* } 11 } */
38     /* { dg-warning "also found .\\-\\(id\\)initWithData:\\(id <MyObject, MyCoding>\\)data." "" { target *-*-* } 19 } */
39     /* { dg-warning "also found .\\-\\(id\\)initWithData:\\(int\\)data." "" { target *-*-* } 15 } */
41     /* The following warning is a consequence of picking the "wrong" method signature.  */
42     /* { dg-warning "passing argument 1 of .initWithData:. from distinct Objective\\-C type" "" { target *-*-* } 35 } */
43     return result;
45 @end