]> gcc.gnu.org Git - gcc.git/blob - gcc/testsuite/objc.dg/desig-init-1.m
fold-const.c (tree_expr_nonnegative_p): Add more builtin cases.
[gcc.git] / gcc / testsuite / objc.dg / desig-init-1.m
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 } */
6
7 #include <stdio.h>
8 #include <objc/objc.h>
9 #include <objc/Object.h>
10
11 @interface Cls : Object
12 + (int) meth1;
13 + (int) meth2;
14 + (void) doTests;
15 @end
16
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] = (size_t)[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 };
31
32 if (arr[0] != 0 || arr[1] != 45 || arr[2] != 21 || arr[3] != 3)
33 abort (); /* { dg-warning "implicit declaration" } */
34
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]);
37 }
38 @end
39
40 int main(void) {
41 [Cls doTests];
42 return 0;
43 }
This page took 0.038088 seconds and 5 git commands to generate.