Debian Codegraph @

gcc/testsuite/c-c++-common/ubsan/sanitize-all-3.c

raw
1 /* Test -f*sanitize*=all */
2 /* { dg-do run } */
3 /* { dg-skip-if "" { *-*-* } { "*" } { "-O2" } } */
4 /* { dg-skip-if "" { *-*-* } { "-flto -fno-fat-lto-objects" } } */
5 /* { dg-options "-fsanitize=undefined -fsanitize-recover=all -fdump-tree-optimized" } */
6
7 int a[4];
8
9 int
10 f1 (int x, int y, int z)
11 {
12 return a[x] + (1 << y) + (100 / z);
13 }
14
15 char *
16 f2 (int x)
17 {
18 char *p = (char *) __builtin_calloc (64, 1);
19 p[x] = 3;
20 return p;
21 }
22
23 int
24 f3 (int x, int *y, double z, double w)
25 {
26 int a[*y];
27 if (x)
28 __builtin_unreachable ();
29 asm volatile ("" : : "r" (&a[0]));
30 return z / w;
31 }
32
33 int
34 main ()
35 {
36 return 0;
37 }
38
39 /* { dg-final { scan-tree-dump "__ubsan_" "optimized" } } */
40 /* { dg-final { scan-tree-dump-not "__ubsan_\[a-z_\]*_abort" "optimized" } } */
41 /* { dg-final { scan-tree-dump "UBSAN_CHECK_" "optimized" } } */