diff options
Diffstat (limited to 'gcc/testsuite/gcc.c-torture/execute/nest-align-1.c')
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/nest-align-1.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/execute/nest-align-1.c b/gcc/testsuite/gcc.c-torture/execute/nest-align-1.c new file mode 100644 index 000000000..548c8878d --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/nest-align-1.c @@ -0,0 +1,40 @@ +/* Test for alignment handling when a variable is accessed by nested + function. */ +/* Origin: Joey Ye <joey.ye@intel.com> */ + +#include <stddef.h> + +typedef int aligned __attribute__((aligned)); +extern void abort (void); + +void +check (int *i) +{ + *i = 20; + if ((((ptrdiff_t) i) & (__alignof__(aligned) - 1)) != 0) + abort (); +} + +void +foo (void) +{ + aligned jj; + void bar () + { + jj = -20; + } + jj = 0; + bar (); + if (jj != -20) + abort (); + check (&jj); + if (jj != 20) + abort (); +} + +int +main() +{ + foo (); + return 0; +} |