1 /* { dg-options "-fno-inline" } */
2 /* Check that stack alignment is not affected by variables not placed
3 on the stack. */
4
5 #include <assert.h>
6
7 #define ALIGNMENT 64
8
test(unsigned n,unsigned p)9 unsigned test(unsigned n, unsigned p)
10 {
11 static struct { char __attribute__((__aligned__(ALIGNMENT))) c; } s;
12 unsigned x;
13
14 assert(__alignof__(s) == ALIGNMENT);
15 asm ("" : "=g" (x), "+m" (s) : "0" (&x));
16
17 return n ? test(n - 1, x) : (x ^ p);
18 }
19
test2(unsigned n,unsigned p)20 unsigned test2(unsigned n, unsigned p)
21 {
22 static struct { char c; } s;
23 unsigned x;
24
25 assert(__alignof__(s) != ALIGNMENT);
26 asm ("" : "=g" (x), "+m" (s) : "0" (&x));
27
28 return n ? test2(n - 1, x) : (x ^ p);
29 }
30
main(int argc,char * argv[])31 int main (int argc, char *argv[] __attribute__((unused)))
32 {
33 unsigned int x, y;
34
35 x = test(argc, 0);
36 x |= test(argc + 1, 0);
37 x |= test(argc + 2, 0);
38
39 y = test2(argc, 0);
40 y |= test2(argc + 1, 0);
41 y |= test2(argc + 2, 0);
42
43 return (x & (ALIGNMENT - 1)) == 0 && (y & (ALIGNMENT - 1)) != 0 ? 1 : 0;
44 }
45