Replace absolute linenrs in objc.dg,obj-c++.dg
[official-gcc.git] / gcc / testsuite / obj-c++.dg / method-16.mm
blob4b691d81d1a3b6e9586fe0928e702fe0e3b9f58a
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>
12 @interface Object1
13 - (void)initWithData:(Object1 *)data; /* { dg-line Object1_initWithData } */
14 @end
16 @interface Object2
17 - (id)initWithData:(Object1 *)data; /* { dg-line Object2_initWithData } */
18 @end
20 @interface Object3
21 - (id)initWithData:(Object2 *)data; /* { dg-line Object3_initWithData } */
22 @end
24 void foo(void) {
25   id obj1, obj2 = 0;
26   obj2 = [obj1 initWithData: obj2]; /* { dg-line obj2_assign } */
27      /* { dg-warning "multiple methods named .\\-initWithData:. found" "" { target *-*-* } .-1 } */
28      /* { dg-message "using .\\-\\(void\\)initWithData:\\(Object1 \\*\\)data." "" { target *-*-* } Object1_initWithData } */
29      /* { dg-message "also found .\\-\\(id\\)initWithData:\\(Object1 \\*\\)data." "" { target *-*-* } Object2_initWithData } */
30      /* { dg-message "also found .\\-\\(id\\)initWithData:\\(Object2 \\*\\)data." "" { target *-*-* } Object3_initWithData } */
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 *-*-* } obj2_assign } */