Small ChangeLog tweak.
[official-gcc.git] / gcc / testsuite / objc.dg / method-11.m
blob60198803e661d1b5aab5f19f7fde9eb5150cc11e
1 /* Ensure that we indeed cannot obtain the value of a message send
2    if the chosen method signature returns 'void'.  There used to
3    exist a cheesy hack that allowed it.  While at it, check that
4    the first lexically occurring method signature gets picked
5    when sending messages to 'id'.  */ 
6 /* Contributed by Ziemowit Laski <zlaski@apple.com>  */
7 /* { dg-do compile } */
9 #include <objc/objc.h>
11 @interface Object1
12 - (void)initWithData:(Object1 *)data; /* { dg-line Object1_initWithData } */
13 @end
15 @interface Object2
16 - (id)initWithData:(Object1 *)data; /* { dg-line Object2_initWithData } */
17 @end
19 @interface Object3
20 - (id)initWithData:(Object2 *)data; /* { dg-line Object3_initWithData } */
21 @end
23 void foo(void) {
24   id obj1, obj2 = 0;
25   obj2 = [obj1 initWithData: obj2]; /* { dg-line initWithData_message } */
26      /* { dg-warning "multiple methods named .\\-initWithData:. found" "" { target *-*-* } .-1 } */
27      /* { dg-message "using .\\-\\(void\\)initWithData:\\(Object1 \\*\\)data." "" { target *-*-* } Object1_initWithData } */
28      /* { dg-message "also found .\\-\\(id\\)initWithData:\\(Object1 \\*\\)data." "" { target *-*-* } Object2_initWithData } */
29      /* { dg-message "also found .\\-\\(id\\)initWithData:\\(Object2 \\*\\)data." "" { target *-*-* } Object3_initWithData } */
31      /* The following error is a consequence of picking the "wrong" method signature.  */
32      /* { dg-error "void value not ignored as it ought to be" "" { target *-*-* } initWithData_message } */