PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / obj-c++.dg / method-15.mm
blobda851c931a43d2daf974c17bbc1f7c159c7ac139
1 /* Check if finding multiple signatures for a method is handled gracefully when method lookup succeeds (see also method-7.m).  */
2 /* Contributed by Ziemowit Laski <zlaski@apple.com>  */
3 /* { dg-options "-Wstrict-selector-match" } */
4 /* { dg-do compile } */
6 #include "../objc-obj-c++-shared/TestsuiteObject.h"
8 @protocol MyObject
9 - (id)initWithData:(TestsuiteObject *)data; /* { dg-line MyObject_initWithData } */
10 @end
12 @protocol SomeOther
13 - (id)initWithData:(int)data; /* { dg-line SomeOther_initWithData } */
14 @end
16 @protocol MyCoding
17 - (id)initWithData:(id<MyObject, MyCoding>)data; /* { dg-line MyCoding_initWithData } */
18 @end
20 @interface NTGridDataObject: TestsuiteObject <MyCoding>
22     TestsuiteObject<MyCoding> *_data;
24 + (NTGridDataObject*)dataObject:(id<MyObject, MyCoding>)data;
25 @end
27 @implementation NTGridDataObject
28 - (id)initWithData:(id<MyObject, MyCoding>)data {
29   return data;
31 + (NTGridDataObject*)dataObject:(id<MyObject, MyCoding>)data
33     NTGridDataObject *result = [[NTGridDataObject alloc] initWithData:data]; /* { dg-line result_init } */
34      /* { dg-warning "multiple methods named .\\-initWithData:. found" "" { target *-*-* } .-1 } */
35      /* { dg-message "using .\\-\\(id\\)initWithData:\\(TestsuiteObject \\*\\)data." "" { target *-*-* } MyObject_initWithData } */
36      /* { dg-message "also found .\\-\\(id\\)initWithData:\\(id <MyObject, MyCoding>\\)data." "" { target *-*-* } MyCoding_initWithData } */
37      /* { dg-message "also found .\\-\\(id\\)initWithData:\\(int\\)data." "" { target *-*-* } SomeOther_initWithData } */
39      /* The following warning is a consequence of picking the "wrong" method signature.  */
40      /* { dg-warning "passing argument 1 of .initWithData:. from distinct Objective\\-C type" "" { target *-*-* } result_init } */
41     return result;
43 @end