1 /* PR c/33238 */
2 /* { dg-require-effective-target alloca } */
3
4 typedef __SIZE_TYPE__ size_t;
5 int memcmp (const void *, const void *, size_t);
6 void abort (void);
7
8 void
9 __attribute__((noinline))
bar(void * x,void * y)10 bar (void *x, void *y)
11 {
12 struct S { char w[8]; } *p = x, *q = y;
13 if (memcmp (p->w, "zyxwvut", 8) != 0)
14 abort ();
15 if (memcmp (q[0].w, "abcdefg", 8) != 0)
16 abort ();
17 if (memcmp (q[1].w, "ABCDEFG", 8) != 0)
18 abort ();
19 if (memcmp (q[2].w, "zyxwvut", 8) != 0)
20 abort ();
21 if (memcmp (q[3].w, "zyxwvut", 8) != 0)
22 abort ();
23 }
24
25 void
26 __attribute__((noinline))
foo(void * x,int y)27 foo (void *x, int y)
28 {
29 struct S { char w[y]; } *p = x, a;
30 int i;
31 a = ({ struct S b; b = p[2]; p[3] = b; });
32 bar (&a, x);
33 }
34
35 int
main(void)36 main (void)
37 {
38 struct S { char w[8]; } p[4]
39 = { "abcdefg", "ABCDEFG", "zyxwvut", "ZYXWVUT" };
40 foo (p, 8);
41 return 0;
42 }
43