annotate gcc/testsuite/c-c++-common/ubsan/align-10.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Limit this to known non-strict alignment targets. */
kono
parents:
diff changeset
2 /* { dg-do run { target { i?86-*-linux* x86_64-*-linux* } } } */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 111
diff changeset
3 /* { dg-options "-O -fsanitize=alignment -fsanitize-recover=alignment -Wno-address-of-packed-member" } */
111
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 struct R { int a; } r;
kono
parents:
diff changeset
6 struct S { struct R a; char b; long long c; short d[10]; };
kono
parents:
diff changeset
7 struct T { char a; long long b; };
kono
parents:
diff changeset
8 struct U { char a; int b; int c; long long d; struct S e; struct T f; } __attribute__((packed));
kono
parents:
diff changeset
9 struct V { long long a; struct S b; struct T c; struct U u; } v;
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 __attribute__((noinline, noclone)) int
kono
parents:
diff changeset
12 bar (int x, struct R y, struct R z)
kono
parents:
diff changeset
13 {
kono
parents:
diff changeset
14 return x + y.a;
kono
parents:
diff changeset
15 }
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 __attribute__((noinline, noclone)) int
kono
parents:
diff changeset
18 foo (struct S *p, struct S *q)
kono
parents:
diff changeset
19 {
kono
parents:
diff changeset
20 int i = bar (0, r, r);
kono
parents:
diff changeset
21 i += bar (1, p->a, r);
kono
parents:
diff changeset
22 i += bar (2, r, q->a);
kono
parents:
diff changeset
23 return i;
kono
parents:
diff changeset
24 }
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 int
kono
parents:
diff changeset
27 main ()
kono
parents:
diff changeset
28 {
kono
parents:
diff changeset
29 char *p = (char *) &v.u.e;
kono
parents:
diff changeset
30 struct S *q, *r;
kono
parents:
diff changeset
31 asm volatile ("" : "=r" (q) : "0" (p));
kono
parents:
diff changeset
32 asm volatile ("" : "=r" (r) : "0" (p));
kono
parents:
diff changeset
33 if (foo (q, r) != 3)
kono
parents:
diff changeset
34 __builtin_abort ();
kono
parents:
diff changeset
35 return 0;
kono
parents:
diff changeset
36 }
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 /* { dg-output "\.c:21:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment.*" } */
kono
parents:
diff changeset
39 /* { dg-output "\.c:22:\[0-9]*: \[^\n\r]*member access within misaligned address 0x\[0-9a-fA-F]* for type 'struct S', which requires \[48] byte alignment" } */