Skip to content

Commit e945d32

Browse files
committed
analyzer: prevent ICEs with null types
Fixes some ICEs seen analyzing the Linux kernel. gcc/analyzer/ChangeLog: * region-model-manager.cc (maybe_undo_optimize_bit_field_compare): Guard against null types. * region-model.cc (apply_constraints_for_gswitch): Likewise. Signed-off-by: David Malcolm <[email protected]>
1 parent 21aa57e commit e945d32

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

gcc/analyzer/region-model-manager.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,8 @@ maybe_undo_optimize_bit_field_compare (tree type,
616616
tree cst,
617617
const svalue *arg1)
618618
{
619+
if (!type)
620+
return nullptr;
619621
if (!INTEGRAL_TYPE_P (type))
620622
return NULL;
621623

gcc/analyzer/region-model.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5781,7 +5781,8 @@ apply_constraints_for_gswitch (const switch_cfg_superedge &edge,
57815781
&& is_a <const initial_svalue *> (unaryop->get_arg ()))
57825782
if (const initial_svalue *initvalop = (as_a <const initial_svalue *>
57835783
(unaryop->get_arg ())))
5784-
if (TREE_CODE (initvalop->get_type ()) == ENUMERAL_TYPE)
5784+
if (initvalop->get_type ()
5785+
&& TREE_CODE (initvalop->get_type ()) == ENUMERAL_TYPE)
57855786
{
57865787
index_sval = initvalop;
57875788
check_index_type = false;

0 commit comments

Comments
 (0)