2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / objc.dg / desig-init-1.m
blob44abe440d7bc7d0dc6167b81413752ff6f31801c
1 /* Test Objective-C capability for handling GNU/C99 designated
2    initializers, and distinguishing them from message sends.  */
3 /* Contributed by Ziemowit Laski <zlaski@apple.com>.  */
4 /* { dg-options "-std=gnu99" } */
5 /* { dg-do run } */
7 #include <stdio.h>           
8 #include <objc/objc.h>
9 #include <objc/Object.h>
11 @interface Cls : Object
12 + (int) meth1;
13 + (int) meth2;
14 + (void) doTests;
15 @end
17 @implementation Cls
18 + (int) meth1 { return 45; }
19 + (int) meth2 { return 21; }
20 + (void) doTests {
21   int arr[6] = { 
22     0, 
23     [Cls meth1], 
24     [2 + 1] = 3, 
25     [2 * 2 ... 5] = (int)[0 meth2], /* { dg-warning "invalid receiver type" } */ 
26        /* { dg-warning "Messages without a matching method signature" "" { target *-*-* } 25 } */
27        /* { dg-warning "will be assumed to return .id. and accept" "" { target *-*-* } 25 } */
28        /* { dg-warning ".\.\.\.. as arguments" "" { target *-*-* } 25 } */
29     [2] [Cls meth2]
30   };
32   if (arr[0] != 0 || arr[1] != 45 || arr[2] != 21 || arr[3] != 3)
33     abort (); /* { dg-warning "implicit declaration" } */
35   printf ("%s\n", [super name]);
36   printf ("%d %d %d %d %d %d\n", arr[0], arr[1], arr[2], arr[3], arr[4], arr[5]);
38 @end
40 int main(void) {
41   [Cls doTests];
42   return 0;