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>
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);
--- /dev/null
+! { 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