1/* Limit this to known non-strict alignment targets.  */
2/* { dg-do run { target { i?86-*-linux* x86_64-*-linux* } } } */
3/* { dg-options "-fsanitize=alignment" } */
4
5struct S { int a; char b; long long c; short d[10]; };
6struct T { char a; long long b; };
7struct U { char a; int b; int c; long long d; struct S e; struct T f; } __attribute__((packed));
8struct V { long long a; struct S b; struct T c; struct U u; } v;
9
10__attribute__((noinline, noclone)) void
11f1 (int *p, int *q, char *r, long long *s)
12{
13  *p =
14      *q
15      + *r
16      + *s;
17}
18
19
20__attribute__((noinline, noclone)) int
21f2 (struct S *p)
22{
23  return p->a;
24}
25
26__attribute__((noinline, noclone)) long long
27f3 (struct S *p, int i)
28{
29  return p->c
30	 + p->d[1]
31	 + p->d[i];
32}
33
34__attribute__((noinline, noclone)) long long
35f4 (long long *p)
36{
37  return *p;
38}
39
40int
41main ()
42{
43  f1 (&v.u.b, &v.u.c, &v.u.a, &v.u.d);
44  if (f2 (&v.u.e) + f3 (&v.u.e, 4) + f4 (&v.u.f.b) != 0)
45    __builtin_abort ();
46  return 0;
47}
48
49/* { dg-output "\.c:(14|15):\[0-9]*: \[^\n\r]*load of misaligned address 0x\[0-9a-fA-F]* for type 'int', which requires 4 byte alignment.*" } */
50/* { dg-output "\.c:16:\[0-9]*: \[^\n\r]*load of misaligned address 0x\[0-9a-fA-F]* for type 'long long int', which requires \[48] byte alignment.*" } */
51/* { dg-output "\.c:(13|16):\[0-9]*: \[^\n\r]*store to misaligned address 0x\[0-9a-fA-F]* for type 'int', which requires 4 byte alignment.*" } */
52/* { dg-output "\.c:23:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment.*" } */
53/* { dg-output "\.c:(29|30):\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment.*" } */
54/* { dg-output "\.c:30:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment.*" } */
55/* { dg-output "\.c:31:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment.*" } */
56/* { dg-output "\.c:37:\[0-9]*: \[^\n\r]*load of misaligned address 0x\[0-9a-fA-F]* for type 'long long int', which requires \[48] byte alignment" } */
57