From: David Malcolm Date: Tue, 2 Apr 2024 21:42:16 +0000 (-0400) Subject: analyzer: prevent ICEs with null types X-Git-Tag: basepoints/gcc-15~377 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e945d322fcbc68f91388b1d1297bdf6a6c6fcbaa;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/analyzer/region-model-manager.cc b/gcc/analyzer/region-model-manager.cc index 4feb349c9142..f155eeb87c0d 100644 --- a/gcc/analyzer/region-model-manager.cc +++ b/gcc/analyzer/region-model-manager.cc @@ -616,6 +616,8 @@ maybe_undo_optimize_bit_field_compare (tree type, tree cst, const svalue *arg1) { + if (!type) + return nullptr; if (!INTEGRAL_TYPE_P (type)) return NULL; diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc index 902b887fc074..98f287145c6c 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -5781,7 +5781,8 @@ apply_constraints_for_gswitch (const switch_cfg_superedge &edge, && is_a (unaryop->get_arg ())) if (const initial_svalue *initvalop = (as_a (unaryop->get_arg ()))) - if (TREE_CODE (initvalop->get_type ()) == ENUMERAL_TYPE) + if (initvalop->get_type () + && TREE_CODE (initvalop->get_type ()) == ENUMERAL_TYPE) { index_sval = initvalop; check_index_type = false;