2 /* Ensure that we indeed cannot obtain the value of a message send
3 if the chosen method signature returns 'void'. There used to
4 exist a cheesy hack that allowed it. While at it, check that
5 the first lexically occurring method signature gets picked
6 when sending messages to 'id'. */
7 /* Contributed by Ziemowit Laski <zlaski@apple.com> */
8 /* { dg-do compile } */
10 #include <objc/objc.h>
13 - (void)initWithData:(Object1 *)data;
17 - (id)initWithData:(Object1 *)data;
21 - (id)initWithData:(Object2 *)data;
26 obj2 = [obj1 initWithData: obj2];
27 /* { dg-warning "multiple methods named .\\-initWithData:. found" "" { target *-*-* } 26 } */
28 /* { dg-warning "using .\\-\\(void\\)initWithData:\\(Object1 \\*\\)data." "" { target *-*-* } 13 } */
29 /* { dg-warning "also found .\\-\\(id\\)initWithData:\\(Object1 \\*\\)data." "" { target *-*-* } 17 } */
30 /* { dg-warning "also found .\\-\\(id\\)initWithData:\\(Object2 \\*\\)data." "" { target *-*-* } 21 } */
32 /* The following error is a consequence of picking the "wrong" method signature. */
33 /* { dg-error "void value not ignored as it ought to be" "" { target *-*-* } 26 } */