public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-9762] analyzer: prevent ICEs with null types
Date: Tue,  2 Apr 2024 21:47:36 +0000 (GMT)	[thread overview]
Message-ID: <20240402214736.5EB7B3858D28@sourceware.org> (raw)

https://gcc.gnu.org/g:e945d322fcbc68f91388b1d1297bdf6a6c6fcbaa

commit r14-9762-ge945d322fcbc68f91388b1d1297bdf6a6c6fcbaa
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Tue Apr 2 17:42:16 2024 -0400

    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>

Diff:
---
 gcc/analyzer/region-model-manager.cc | 2 ++
 gcc/analyzer/region-model.cc         | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/gcc/analyzer/region-model-manager.cc b/gcc/analyzer/region-model-manager.cc
index 4feb349c914..f155eeb87c0 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 902b887fc07..98f287145c6 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;

                 reply	other threads:[~2024-04-02 21:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240402214736.5EB7B3858D28@sourceware.org \
    --to=dmalcolm@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).