| 1 |
/* Limit this to known non-strict alignment targets. */ |
| 2 |
/* { dg-do run { target { i?86-*-linux* x86_64-*-linux* } } } */ |
| 3 |
/* { dg-options "-O -fsanitize=alignment -fsanitize-recover=alignment -Wno-address-of-packed-member" } */ |
| 4 |
|
| 5 |
struct S { int a; char b; long long c; short d[10]; }; |
| 6 |
struct T { char a; long long b; }; |
| 7 |
struct U { char a; int b; int c; long long d; struct S e; struct T f; } __attribute__((packed)); |
| 8 |
struct V { long long a; struct S b; struct T c; struct U u; } v; |
| 9 |
|
| 10 |
__attribute__((noinline, noclone)) int |
| 11 |
foo (struct S *p) |
| 12 |
{ |
| 13 |
volatile int i; |
| 14 |
i = p->a; |
| 15 |
i = p->a; |
| 16 |
i = p->a; |
| 17 |
i = p->a; |
| 18 |
return p->a; |
| 19 |
} |
| 20 |
|
| 21 |
int |
| 22 |
main () |
| 23 |
{ |
| 24 |
if (foo (&v.u.e)) |
| 25 |
__builtin_abort (); |
| 26 |
return 0; |
| 27 |
} |
| 28 |
|
| 29 |
/* { dg-output "\.c:14:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment.*" } */ |
| 30 |
/* { dg-output "\.c:15:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment.*" } */ |
| 31 |
/* { dg-output "\.c:16:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment.*" } */ |
| 32 |
/* { dg-output "\.c:17:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment.*" } */ |
| 33 |
/* { dg-output "\.c:18:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment" } */ |