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)); 8 extern void abort (void); 9 10 void check(int * i)11check (int *i) 12 { 13 *i = 20; 14 if ((((ptrdiff_t) i) & (__alignof__(aligned) - 1)) != 0) 15 abort (); 16 } 17 18 void foo(void)19foo (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 main()36main() 37 { 38 foo (); 39 return 0; 40 } 41