1 /* Test for GNU extensions to C99 designated initializers */
2 /* Origin: Jakub Jelinek <jakub@redhat.com> */
4 /* { dg-options "-std=gnu99" } */
6 typedef __SIZE_TYPE__ size_t;
7 extern int memcmp (const void *, const void *, size_t);
8 extern void abort (void);
9 extern void exit (int);
11 int a[][2][4] = { [2 ... 4][0 ... 1][2 ... 3] = 1, [2] = 2, [2][0][2] = 3 };
13 struct F { struct E H; };
14 struct G { int I; struct E J; int K; };
15 struct H { int I; struct F J; int K; };
16 struct G k = { .J = {}, 1 };
17 struct H l = { .J.H = {}, 2 };
18 struct H m = { .J = {}, 3 };
19 struct I { int J; int K[3]; int L; };
20 struct M { int N; struct I O[3]; int P; };
21 struct M n[] = { [0 ... 5].O[1 ... 2].K[0 ... 1] = 4, 5, 6, 7 };
22 struct M o[] = { [0 ... 5].O = { [1 ... 2].K[0 ... 1] = 4 },
23 [5].O[2].K[2] = 5, 6, 7 };
24 struct M p[] = { [0 ... 5].O[1 ... 2].K = { [0 ... 1] = 4 },
25 [5].O[2].K[2] = 5, 6, 7 };
26 int q[3][3] = { [0 ... 1] = { [1 ... 2] = 23 }, [1][2] = 24 };
27 int r[1] = { [0 ... 1 - 1] = 27 };
33 if (a[2][0][0] != 2 || a[2][0][2] != 3)
37 for (x = 0; x <= 4; x++)
38 for (y = 0; y <= 1; y++)
39 for (z = 0; z <= 3; z++)
40 if (a[x][y][z] != (x >= 2 && z >= 2))
42 if (k.I || l.I || m.I || k.K != 1 || l.K != 2 || m.K != 3)
44 for (x = 0; x <= 5; x++)
46 if (n[x].N || n[x].O[0].J || n[x].O[0].L)
48 for (y = 0; y <= 2; y++)
51 for (y = 1; y <= 2; y++)
55 if (n[x].O[y].K[0] != 4)
57 if (n[x].O[y].K[1] != 4)
59 if ((x < 5 || y < 2) && (n[x].O[y].K[2] || n[x].O[y].L))
65 if (n[5].O[2].K[2] != 5 || n[5].O[2].L != 6 || n[5].P != 7)
67 if (memcmp (n, o, sizeof (n)) || sizeof (n) != sizeof (o))
69 if (memcmp (n, p, sizeof (n)) || sizeof (n) != sizeof (p))
71 if (q[0][0] || q[0][1] != 23 || q[0][2] != 23)
73 if (q[1][0] || q[1][1] != 23 || q[1][2] != 24)
75 if (q[2][0] || q[2][1] || q[2][2])