]> gcc.gnu.org Git - gcc.git/blob - gcc/testsuite/obj-c++.dg/method-15.mm
PR c++/92590 - wrong handling of inherited default ctor.
[gcc.git] / gcc / testsuite / obj-c++.dg / method-15.mm
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 } */
5
6 #include "../objc-obj-c++-shared/TestsuiteObject.h"
7
8 @protocol MyObject
9 - (id)initWithData:(TestsuiteObject *)data; /* { dg-line MyObject_initWithData } */
10 @end
11
12 @protocol SomeOther
13 - (id)initWithData:(int)data; /* { dg-line SomeOther_initWithData } */
14 @end
15
16 @protocol MyCoding
17 - (id)initWithData:(id<MyObject, MyCoding>)data; /* { dg-line MyCoding_initWithData } */
18 @end
19
20 @interface NTGridDataObject: TestsuiteObject <MyCoding>
21 {
22 TestsuiteObject<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]; /* { 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 } */
38
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;
42 }
43 @end
This page took 0.037967 seconds and 5 git commands to generate.