OSDN Git Service

gcc/
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.c-torture / execute / nest-align-1.c
1 /* Test for alignment handling when a variable is accessed by nested
2    function.  */
3 /* Origin: Joey Ye <joey.ye@intel.com> */
4
5 #include <stddef.h>
6
7 typedef int aligned __attribute__((aligned(16)));
8 extern void abort (void);
9
10 void
11 check (int *i)
12 {
13   *i = 20;
14   if ((((ptrdiff_t) i) & (__alignof__(aligned) - 1)) != 0)
15     abort ();
16 }
17
18 void
19 foo (void)
20 {
21   aligned jj;
22   void bar ()
23     {
24       jj = -20;
25     }
26   jj = 0;
27   bar ();
28   if (jj != -20)
29     abort ();
30   check (&jj);
31   if (jj != 20)
32     abort ();
33 }
34
35 int
36 main()
37 {
38   foo ();
39   return 0;
40 }