* gcc.target/i386/mpx/hard-reg-1-nov.c (mpx_test): Use "esp"
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / stkalign.c
blobe10a1d2ec24fb4e58552c5b038969c99118c324a
1 /* { dg-options "-fno-inline" } */
2 /* Check that stack alignment is not affected by variables not placed
3 on the stack. */
5 #include <assert.h>
7 #define ALIGNMENT 64
9 unsigned test(unsigned n, unsigned p)
11 static struct { char __attribute__((__aligned__(ALIGNMENT))) c; } s;
12 unsigned x;
14 assert(__alignof__(s) == ALIGNMENT);
15 asm ("" : "=g" (x), "+m" (s) : "0" (&x));
17 return n ? test(n - 1, x) : (x ^ p);
20 unsigned test2(unsigned n, unsigned p)
22 static struct { char c; } s;
23 unsigned x;
25 assert(__alignof__(s) != ALIGNMENT);
26 asm ("" : "=g" (x), "+m" (s) : "0" (&x));
28 return n ? test2(n - 1, x) : (x ^ p);
31 int main (int argc, char *argv[] __attribute__((unused)))
33 unsigned int x, y;
35 x = test(argc, 0);
36 x |= test(argc + 1, 0);
37 x |= test(argc + 2, 0);
39 y = test2(argc, 0);
40 y |= test2(argc + 1, 0);
41 y |= test2(argc + 2, 0);
43 return (x & (ALIGNMENT - 1)) == 0 && (y & (ALIGNMENT - 1)) != 0 ? 1 : 0;