| 1 |
/* Test for alignment handling when a variable is accessed by nested |
| 2 |
function. */ |
| 3 |
/* Origin: Joey Ye <[email protected]> */ |
| 4 |
|
| 5 |
/* Force bigger stack alignment for PowerPC EABI targets. */ |
| 6 |
/* { dg-options "-mno-eabi" { target powerpc-*-eabi* } } */ |
| 7 |
|
| 8 |
#include <stddef.h> |
| 9 |
|
| 10 |
typedef int aligned __attribute__((aligned)); |
| 11 |
extern void abort (void); |
| 12 |
|
| 13 |
void |
| 14 |
check (int *i) |
| 15 |
{ |
| 16 |
*i = 20; |
| 17 |
if ((((ptrdiff_t) i) & (__alignof__(aligned) - 1)) != 0) |
| 18 |
abort (); |
| 19 |
} |
| 20 |
|
| 21 |
void |
| 22 |
foo (void) |
| 23 |
{ |
| 24 |
aligned jj; |
| 25 |
void bar () |
| 26 |
{ |
| 27 |
jj = -20; |
| 28 |
} |
| 29 |
jj = 0; |
| 30 |
bar (); |
| 31 |
if (jj != -20) |
| 32 |
abort (); |
| 33 |
check (&jj); |
| 34 |
if (jj != 20) |
| 35 |
abort (); |
| 36 |
} |
| 37 |
|
| 38 |
int |
| 39 |
main() |
| 40 |
{ |
| 41 |
foo (); |
| 42 |
return 0; |
| 43 |
} |