* ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch
[official-gcc.git] / gcc / testsuite / c-c++-common / ubsan / align-2.c
blob071de8c202a782b7bf363edd196b9ce15ce3f9f3
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" } */
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;
10 __attribute__((noinline, noclone)) void
11 f1 (int *p, int *q, char *r, long long *s)
13 *p =
15 + *r
16 + *s;
20 __attribute__((noinline, noclone)) int
21 f2 (struct S *p)
23 return p->a;
26 __attribute__((noinline, noclone)) long long
27 f3 (struct S *p, int i)
29 return p->c
30 + p->d[1]
31 + p->d[i];
34 __attribute__((noinline, noclone)) long long
35 f4 (long long *p)
37 return *p;
40 int
41 main ()
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;
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" } */