View | Details | Return to bug 58970 | Differences between
and this patch

Collapse All | Expand All

(-)gcc/expr.c.jj (-7 / +15 lines)
Lines 4573-4592 get_bit_range (unsigned HOST_WIDE_INT *b Link Here
4573
  bitoffset += (tree_low_cst (DECL_FIELD_BIT_OFFSET (field), 1)
4573
  bitoffset += (tree_low_cst (DECL_FIELD_BIT_OFFSET (field), 1)
4574
		- tree_low_cst (DECL_FIELD_BIT_OFFSET (repr), 1));
4574
		- tree_low_cst (DECL_FIELD_BIT_OFFSET (repr), 1));
4575
4575
4576
  if (*bitpos < 0)
4577
    {
4578
      gcc_assert (*offset == NULL_TREE);
4579
      *offset = size_int (*bitpos >> (BITS_PER_UNIT == 8
4580
				      ? 3 : exact_log2 (BITS_PER_UNIT)));
4581
      *bitpos &= BITS_PER_UNIT - 1;
4582
    }
4583
4576
  /* If the adjustment is larger than bitpos, we would have a negative bit
4584
  /* If the adjustment is larger than bitpos, we would have a negative bit
4577
     position for the lower bound and this may wreak havoc later.  This can
4585
     position for the lower bound and this may wreak havoc later.  Adjust
4578
     occur only if we have a non-null offset, so adjust offset and bitpos
4586
     offset and bitpos to make the lower bound non-negative in that case.  */
4579
     to make the lower bound non-negative.  */
4580
  if (bitoffset > *bitpos)
4587
  if (bitoffset > *bitpos)
4581
    {
4588
    {
4582
      HOST_WIDE_INT adjust = bitoffset - *bitpos;
4589
      HOST_WIDE_INT adjust = bitoffset - *bitpos;
4583
4584
      gcc_assert ((adjust % BITS_PER_UNIT) == 0);
4590
      gcc_assert ((adjust % BITS_PER_UNIT) == 0);
4585
      gcc_assert (*offset != NULL_TREE);
4586
4591
4587
      *bitpos += adjust;
4592
      *bitpos += adjust;
4588
      *offset
4593
      if (*offset == NULL_TREE)
4589
	= size_binop (MINUS_EXPR, *offset, size_int (adjust / BITS_PER_UNIT));
4594
	*offset = size_int (-adjust / BITS_PER_UNIT);
4595
      else
4596
	*offset
4597
	  = size_binop (MINUS_EXPR, *offset, size_int (adjust / BITS_PER_UNIT));
4590
      *bitstart = 0;
4598
      *bitstart = 0;
4591
    }
4599
    }
4592
  else
4600
  else
(-)gcc/testsuite/gcc.c-torture/compile/pr58970.c.jj (+11 lines)
Line 0 Link Here
1
/* PR middle-end/58970 */
2
3
struct T { int b : 1; };
4
struct S { struct T t[1]; };
5
6
void
7
foo (int x, struct S *s)
8
{
9
  if (x == -1)
10
    s->t[x].b = 0;
11
}

Return to bug 58970