> Hmm, yeah.  Or something like
>
> Index: expr.c
> ===================================================================
> --- expr.c      (revision 186082)
> +++ expr.c      (working copy)
> @@ -4490,8 +4490,8 @@ get_bit_range (unsigned HOST_WIDE_INT *b
>    bitoffset += (tree_low_cst (DECL_FIELD_BIT_OFFSET (field), 1)
>                 - tree_low_cst (DECL_FIELD_BIT_OFFSET (repr), 1));
>
> -  *bitstart = bitpos - bitoffset;
> -  *bitend = *bitstart + tree_low_cst (DECL_SIZE (repr), 1) - 1;
> +  *bitstart = bitpos < (HOST_WIDE_INT) bitoffset ? 0 : bitpos -
> bitoffset;
> +  *bitend = bitpos + tree_low_cst (DECL_SIZE (repr), 1) - bitoffset - 1;
>  }
>
>  /* Returns true if the MEM_REF REF refers to an object that does not
>
> which conservatively truncates the bitrange.

What do you think about allowing get_bit_range to adjust offset and bitpos?

      tem = get_inner_reference (to, &bitsize, &bitpos, &offset, &mode1,
                                 &unsignedp, &volatilep, true);

      if (TREE_CODE (to) == COMPONENT_REF
          && DECL_BIT_FIELD_TYPE (TREE_OPERAND (to, 1)))
        get_bit_range (&bitregion_start, &bitregion_end, &offset, &bitpos, to);

so as to have a really non-negative bitregion_start/bitregion_end?  It would 
assert that offset is already non-null in that case.

-- 
Eric Botcazou

Reply via email to