aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2024-04-02 17:42:16 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2024-04-02 17:42:16 -0400
commite945d322fcbc68f91388b1d1297bdf6a6c6fcbaa (patch)
treeb7b6363a0616a78a1a8b6bb2b6989d125e96cd60 /gcc
parent21aa57e73b820395b7b01843d61ef5b84cd20d02 (diff)
downloadgcc-e945d322fcbc68f91388b1d1297bdf6a6c6fcbaa.zip
gcc-e945d322fcbc68f91388b1d1297bdf6a6c6fcbaa.tar.gz
gcc-e945d322fcbc68f91388b1d1297bdf6a6c6fcbaa.tar.bz2
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 <dmalcolm@redhat.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/analyzer/region-model-manager.cc2
-rw-r--r--gcc/analyzer/region-model.cc3
2 files changed, 4 insertions, 1 deletions
diff --git a/gcc/analyzer/region-model-manager.cc b/gcc/analyzer/region-model-manager.cc
index 4feb349..f155eeb 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 902b887..98f2871 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 <const initial_svalue *> (unaryop->get_arg ()))
if (const initial_svalue *initvalop = (as_a <const initial_svalue *>
(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;