1 /* Test for C99 designated initializers */
2 /* Origin: Jakub Jelinek <jakub@redhat.com> */
4 /* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
6 typedef __SIZE_TYPE__
size_t;
7 typedef __WCHAR_TYPE__
wchar_t;
8 extern int memcmp (const void *, const void *, size_t);
9 extern void abort (void);
10 extern void exit (int);
12 int a
[10] = { 10, 0, 12, 13, 14, 0, 0, 17, 0, 0 };
13 int b
[10] = { 10, [4] = 15, [2] = 12, [4] = 14, [7] = 17 };
14 int c
[10] = { 10, [4] = 15, [2] = 12, [3] = 13, 14, [7] = 17 };
19 struct A d
[] = { { 0, { 1, 2 } }, { 0, { 0, 0 } }, { 10, { 11, 12 } } };
20 struct A e
[] = { 0, 1, 2, [2] = 10, 11, 12 };
21 struct A f
[] = { 0, 1, 2, [2].C
= 11, 12, 13 };
22 struct A g
[] = { 0, 1, 2, [2].C
[1] = 12, 13, 14 };
23 struct A h
[] = { 0, 1, 2, [2] = { .C
[1] = 12 }, 13, 14 };
24 struct A i
[] = { 0, 1, 2, [2] = { .C
= { [1] = 12 } }, 13, 14 };
30 union D j
[] = { [4] = 1, [4].F
= 1.0, [1].G
.C
[1] = 4 };
34 } k
[] = { { { "foo" }, 1 }, [0].I
[0] = 'b' };
38 } l
[] = { { { L
"foo" }, 1 }, [0].L
[2] = L
'x', [0].L
[4] = L
'y' };
39 struct H m
[] = { { { "foo" }, 1 }, [0] = { .I
[0] = 'b' } };
40 struct H n
[] = { { { "foo" }, 1 }, [0].I
= { "a" }, [0].J
= 2 };
48 if (memcmp (a
, b
, sizeof (a
)) || memcmp (a
, c
, sizeof (a
)))
50 if (memcmp (d
, e
, sizeof (d
)) || sizeof (d
) != sizeof (e
))
52 if (f
[2].B
!= 0 || g
[2].B
!= 0 || g
[2].C
[0] != 0)
54 if (memcmp (g
, h
, sizeof (g
)) || memcmp (g
, i
, sizeof (g
)))
59 if (memcmp (d
, f
, sizeof (d
)) || memcmp (d
, g
, sizeof (d
)))
61 if (f
[3].B
!= 13 || g
[3].B
!= 13 || g
[3].C
[0] != 14)
63 if (j
[0].E
|| j
[1].G
.B
|| j
[1].G
.C
[0] || j
[1].G
.C
[1] != 4)
65 if (j
[2].E
|| j
[3].E
|| j
[4].F
!= 1.0)
67 if (memcmp (k
[0].I
, "boo\0\0", 6) || k
[0].J
!= 1)
69 if (memcmp (l
[0].L
, L
"fox\0y", 6 * sizeof(wchar_t)) || l
[0].M
!= 1)
71 if (memcmp (m
[0].I
, "b\0\0\0\0", 6) || m
[0].J
)
73 if (memcmp (n
[0].I
, "a\0\0\0\0", 6) || n
[0].J
!= 2)