blob: 71f2e58ea670ac9b019d0c2813c28b89b8c64f6b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
/* { dg-do compile } */
/* { dg-options "-fsanitize=undefined -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow" } */
/* Test that we don't instrument functions marked with
no_sanitize_undefined attribute. */
#ifndef __cplusplus
#define bool _Bool
#endif
enum A { B = -3, C = 2 } a;
bool b;
__attribute__((no_sanitize_undefined))
static void
vla_bound (void)
{
int i = -1;
volatile int a[i];
}
__attribute__((no_sanitize_undefined))
static void
si_overflow (void)
{
int x = 123, y = 267;
volatile int z1 = x + y;
volatile int z2 = x - y;
volatile int z3 = x * y;
volatile int z4 = x / y;
}
__attribute__((no_sanitize_undefined))
static void
null (int *p)
{
*p = 42;
}
__attribute__((no_sanitize_undefined))
static void
retrn (int *p)
{
*p = 42;
}
__attribute__((no_sanitize_undefined))
static enum A
bool_enum (bool *p)
{
*p = b;
return a;
}
__attribute__((no_sanitize_undefined))
static void
float_zero (void)
{
volatile float a = 4.2f, b = 0.0f, c;
c = a / b;
}
__attribute__((no_sanitize_undefined))
static void
float_cast (void)
{
volatile double d = 300;
volatile signed char c;
c = d;
}
/* { dg-final { scan-assembler-not "__ubsan_handle" } } */
|