2014-07-29 Ed Smith-Rowland <3dw4rd@verizon.net>
[official-gcc.git] / gcc / testsuite / gcc.dg / array-init-2.c
blob9c425818fe540a0aabc1062b799dac22dff36182
1 /* Test array initializion by store_by_pieces. */
2 /* { dg-do run } */
3 /* { dg-options "-O2" } */
5 struct A { char c[10]; };
6 extern void abort (void);
8 void
9 __attribute__((noinline))
10 check (struct A * a, int b)
12 const char *p;
13 switch (b)
15 case 0:
16 p = "abcdefghi";
17 break;
18 case 1:
19 p = "j\0\0\0\0\0\0\0\0";
20 break;
21 case 2:
22 p = "kl\0\0\0\0\0\0\0";
23 break;
24 case 3:
25 p = "mnop\0\0\0\0\0";
26 break;
27 case 4:
28 p = "qrstuvwx\0";
29 break;
30 default:
31 abort ();
33 if (__builtin_memcmp (a->c, p, 10) != 0)
34 abort ();
37 int
38 main (void)
40 struct A a = { "abcdefghi" };
41 check (&a, 0);
42 struct A b = { "j" };
43 check (&b, 1);
44 struct A c = { "kl" };
45 check (&c, 2);
46 struct A d = { "mnop" };
47 check (&d, 3);
48 struct A e = { "qrstuvwx" };
49 check (&e, 4);
50 return 0;