| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -fdump-tree-isolate-paths -fdelete-null-pointer-checks -Wnull-dereference" } */ |
| 3 |
/* { dg-skip-if "" keeps_null_pointer_checks } */ |
| 4 |
|
| 5 |
|
| 6 |
struct demangle_component |
| 7 |
{ |
| 8 |
|
| 9 |
int type; |
| 10 |
int zzz; |
| 11 |
|
| 12 |
}; |
| 13 |
|
| 14 |
|
| 15 |
struct d_info |
| 16 |
{ |
| 17 |
struct demangle_component *comps; |
| 18 |
int next_comp; |
| 19 |
int num_comps; |
| 20 |
}; |
| 21 |
|
| 22 |
|
| 23 |
static struct demangle_component * |
| 24 |
d_make_empty (struct d_info *di) |
| 25 |
{ |
| 26 |
struct demangle_component *p; |
| 27 |
|
| 28 |
if (di->next_comp >= di->num_comps) |
| 29 |
return ((void *)0); |
| 30 |
p = &di->comps[di->next_comp]; |
| 31 |
return p; |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
struct demangle_component * |
| 37 |
d_type (struct d_info *di) |
| 38 |
{ |
| 39 |
struct demangle_component *ret; |
| 40 |
ret = d_make_empty (di); |
| 41 |
ret->type = 42; /* { dg-warning "null pointer dereference" } */ |
| 42 |
ret->zzz = -1; /* { dg-warning "null pointer dereference" } */ |
| 43 |
return ret; |
| 44 |
} |
| 45 |
|
| 46 |
/* We're testing three aspects of isolation here. First that isolation |
| 47 |
occurs, second that if we have two null dereferences in a block that |
| 48 |
that we delete everything from the first dereferece to the end of the |
| 49 |
block, regardless of which comes first in the immediate use iterator |
| 50 |
and finally that we set the RHS of the store to zero. */ |
| 51 |
/* { dg-final { scan-tree-dump-times "__builtin_trap" 1 "isolate-paths"} } */ |
| 52 |
/* { dg-final { scan-tree-dump-times "->type = 42" 1 "isolate-paths"} } */ |
| 53 |
/* { dg-final { scan-tree-dump-times "->type ={v} 0" 1 "isolate-paths"} } */ |
| 54 |
/* { dg-final { scan-tree-dump-times "->zzz" 1 "isolate-paths"} } */ |