]>
Commit | Line | Data |
---|---|---|
c466b2cd KVH |
1 | /* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */ |
2 | /* Test incremental initializers for char16_t/char32_t arrays. */ | |
5b21d7b2 | 3 | /* { dg-do run { target int32plus } } */ |
c466b2cd KVH |
4 | /* { dg-options "-std=gnu99" } */ |
5 | ||
6 | typedef __SIZE_TYPE__ size_t; | |
ad914b4e JM |
7 | typedef __CHAR16_TYPE__ char16_t; |
8 | typedef __CHAR32_TYPE__ char32_t; | |
c466b2cd KVH |
9 | |
10 | extern int memcmp (const void *, const void *, size_t); | |
11 | extern void abort (void); | |
12 | extern void exit (int); | |
13 | ||
14 | struct A { | |
15 | char16_t S[6]; | |
16 | int M; | |
17 | } a[] = { { { u"foo" }, 1 }, [0].S[2] = u'x', [0].S[4] = u'y' }; | |
18 | struct A b[] = { { { u"foo" }, 1 }, [0] = { .S[0] = u'b' } }; | |
19 | struct A c[] = { { { u"foo" }, 1 }, [0].S = { u"a" }, [0].M = 2 }; | |
20 | ||
21 | struct B { | |
22 | char32_t S[6]; | |
23 | int M; | |
24 | } d[] = { { { U"foo" }, 1 }, [0].S[2] = U'x', [0].S[4] = U'y' }; | |
25 | struct B e[] = { { { U"foo" }, 1 }, [0] = { .S[0] = U'b' } }; | |
26 | struct B f[] = { { { U"foo" }, 1 }, [0].S = { U"a" }, [0].M = 2 }; | |
27 | ||
28 | int main (void) | |
29 | { | |
30 | if (memcmp (a[0].S, u"fox\0y", 6 * sizeof(char16_t)) || a[0].M != 1) | |
31 | abort (); | |
32 | if (memcmp (b[0].S, u"b\0\0\0\0", 6) || b[0].M) | |
33 | abort (); | |
34 | if (memcmp (c[0].S, u"a\0\0\0\0", 6) || c[0].M != 2) | |
35 | abort (); | |
36 | ||
37 | if (memcmp (d[0].S, U"fox\0y", 6 * sizeof(char32_t)) || d[0].M != 1) | |
38 | abort (); | |
39 | if (memcmp (e[0].S, U"b\0\0\0\0", 6) || e[0].M) | |
40 | abort (); | |
41 | if (memcmp (f[0].S, U"a\0\0\0\0", 6) || f[0].M != 2) | |
42 | abort (); | |
43 | ||
44 | exit(0); | |
45 | } |