[C++ PATCH] Deprecate -ffriend-injection
[official-gcc.git] / gcc / testsuite / objc.dg / method-9.m
blobce2d19b2cd170ef66e8c87f75ed711be1ee80748
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 /* { dg-options "-Wstrict-selector-match" } */
8 #include "../objc-obj-c++-shared/TestsuiteObject.h"
10 @protocol MyObject
11 - (id)initWithData:(TestsuiteObject *)data; /* { dg-line MyObject_initWithData } */
12 @end
14 @protocol SomeOther
15 - (id)initWithData:(int)data; /* { dg-line SomeOther_initWithData } */
16 @end
18 @protocol MyCoding
19 - (id)initWithData:(id<MyObject, MyCoding>)data; /* { dg-line MyCoding_initWithData } */
20 @end
22 @interface NTGridDataObject: TestsuiteObject <MyCoding>
24     TestsuiteObject<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]; /* { dg-line initWithData_message } */
36     /* { dg-warning "multiple methods named .\\-initWithData:. found" "" { target *-*-* } .-1 } */
37     /* { dg-message "using .\\-\\(id\\)initWithData:\\(TestsuiteObject \\*\\)data." "" { target *-*-* } MyObject_initWithData } */
38     /* { dg-message "also found .\\-\\(id\\)initWithData:\\(id <MyObject, MyCoding>\\)data." "" { target *-*-* } MyCoding_initWithData } */
39     /* { dg-message "also found .\\-\\(id\\)initWithData:\\(int\\)data." "" { target *-*-* } SomeOther_initWithData } */
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 *-*-* } initWithData_message } */
43     return result;
45 @end