From: David Malcolm <dmalcolm@redhat.com>
To: gcc-patches@gcc.gnu.org
Cc: David Malcolm <dmalcolm@redhat.com>
Subject: [committed] analyzer: fix ICE introduced in r13-3168 [PR107210]
Date: Thu, 13 Oct 2022 16:13:32 -0400 [thread overview]
Message-ID: <20221013201332.1157829-1-dmalcolm@redhat.com> (raw)
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Pushed to trunk as r13-3285-g99da523359e933.
gcc/analyzer/ChangeLog:
PR analyzer/107210
* svalue.cc (constant_svalue::maybe_fold_bits_within): Only
attempt to extract individual bits when tree_fits_uhwi_p.
gcc/testsuite/ChangeLog:
PR analyzer/107210
* gfortran.dg/analyzer/pr107210.f90: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
---
gcc/analyzer/svalue.cc | 3 ++-
gcc/testsuite/gfortran.dg/analyzer/pr107210.f90 | 16 ++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gfortran.dg/analyzer/pr107210.f90
diff --git a/gcc/analyzer/svalue.cc b/gcc/analyzer/svalue.cc
index a0838c0f588..4b00a81b31d 100644
--- a/gcc/analyzer/svalue.cc
+++ b/gcc/analyzer/svalue.cc
@@ -884,7 +884,8 @@ constant_svalue::maybe_fold_bits_within (tree type,
if (bits.m_size_in_bits == 1
&& TREE_CODE (m_cst_expr) == INTEGER_CST
&& type
- && INTEGRAL_TYPE_P (type))
+ && INTEGRAL_TYPE_P (type)
+ && tree_fits_uhwi_p (m_cst_expr))
{
unsigned HOST_WIDE_INT bit = bits.m_start_bit_offset.to_uhwi ();
unsigned HOST_WIDE_INT mask = (1 << bit);
diff --git a/gcc/testsuite/gfortran.dg/analyzer/pr107210.f90 b/gcc/testsuite/gfortran.dg/analyzer/pr107210.f90
new file mode 100644
index 00000000000..6132db48817
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/analyzer/pr107210.f90
@@ -0,0 +1,16 @@
+! { dg-additional-options "-O1" }
+
+subroutine check_int (j)
+ INTEGER(4) :: i, ia(5), ib(5,4), ip, ipa(:)
+ target :: ib
+ POINTER :: ip, ipa
+ logical :: l(5)
+
+ ipa=>ib(2:3,1)
+
+ l = (/ sizeof(i) == 4, sizeof(ia) == 20, sizeof(ib) == 80, &
+ sizeof(ip) == 4, sizeof(ipa) == 8 /)
+
+ if (any(.not.l)) STOP 4
+
+end subroutine check_int
--
2.26.3
reply other threads:[~2022-10-13 20:13 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=20221013201332.1157829-1-dmalcolm@redhat.com \
--to=dmalcolm@redhat.com \
--cc=gcc-patches@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).