blob: 3c46f2890821f3117b1a687777ad9ace18e4d30b (
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
|
#define NULL ((void *)0)
void calling_null_fn_ptr_1 (void)
{
void (*fn_ptr) (void) = NULL;
fn_ptr (); /* { dg-warning "jump through null pointer" } */
}
int calling_null_fn_ptr_2 (void)
{
int (*fn_ptr) (void) = NULL;
return fn_ptr (); /* { dg-warning "jump through null pointer" } */
}
typedef void (*void_void_fn_ptr) (void);
void calling_const_fn_ptr (void)
{
void_void_fn_ptr fn_ptr = (void_void_fn_ptr)0xffd2;
return fn_ptr ();
}
void skipping_init (int flag)
{
void_void_fn_ptr fn_ptr = NULL;
if (flag) /* { dg-message "branch" } */
fn_ptr = (void_void_fn_ptr)0xffd2;
fn_ptr (); /* { dg-warning "jump through null pointer" } */
}
struct callbacks
{
void_void_fn_ptr on_redraw;
void_void_fn_ptr on_cleanup;
};
void test_callbacks (void)
{
struct callbacks cb;
__builtin_memset (&cb, 0, sizeof (cb));
cb.on_cleanup (); /* { dg-warning "jump through null pointer" } */
}
|