]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
analyzer: prevent ICEs with null types
authorDavid Malcolm <dmalcolm@redhat.com>
Tue, 2 Apr 2024 21:42:16 +0000 (17:42 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Tue, 2 Apr 2024 21:42:16 +0000 (17:42 -0400)
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>
gcc/analyzer/region-model-manager.cc
gcc/analyzer/region-model.cc

index 4feb349c9142e6a5044f50b9d0afcccb08d072af..f155eeb87c0d6c21ec542249d8707310f8589368 100644 (file)
@@ -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;
 
index 902b887fc0741c64a55aa055c620dab34d414967..98f287145c6cb3972b8b7133a43ede0addd69967 100644 (file)
@@ -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;