Commit fda1ba0a by Jakub Jelinek Committed by Jakub Jelinek

re PR middle-end/58970 (internal compiler error: in get_bit_range, at expr.c:4562)

	PR middle-end/58970
	* expr.c (get_bit_range): Handle *offset == NULL_TREE.
	(expand_assignment): If *bitpos is negative, set *offset
	and adjust *bitpos, so that it is not negative.

	* gcc.c-torture/compile/pr58970.c: New test.

From-SVN: r204444
parent 10180dd3
2013-11-06 Jakub Jelinek <jakub@redhat.com>
PR middle-end/58970
* expr.c (get_bit_range): Handle *offset == NULL_TREE.
(expand_assignment): If *bitpos is negative, set *offset
and adjust *bitpos, so that it is not negative.
2013-11-06 Ganesh Gopalasubramanian <Ganesh.Gopalasubramanian@amd.com> 2013-11-06 Ganesh Gopalasubramanian <Ganesh.Gopalasubramanian@amd.com>
* config/i386/bdver3.md : Added two additional decoder units * config/i386/bdver3.md : Added two additional decoder units
...@@ -4576,19 +4576,19 @@ get_bit_range (unsigned HOST_WIDE_INT *bitstart, ...@@ -4576,19 +4576,19 @@ get_bit_range (unsigned HOST_WIDE_INT *bitstart,
- tree_low_cst (DECL_FIELD_BIT_OFFSET (repr), 1)); - tree_low_cst (DECL_FIELD_BIT_OFFSET (repr), 1));
/* If the adjustment is larger than bitpos, we would have a negative bit /* If the adjustment is larger than bitpos, we would have a negative bit
position for the lower bound and this may wreak havoc later. This can position for the lower bound and this may wreak havoc later. Adjust
occur only if we have a non-null offset, so adjust offset and bitpos offset and bitpos to make the lower bound non-negative in that case. */
to make the lower bound non-negative. */
if (bitoffset > *bitpos) if (bitoffset > *bitpos)
{ {
HOST_WIDE_INT adjust = bitoffset - *bitpos; HOST_WIDE_INT adjust = bitoffset - *bitpos;
gcc_assert ((adjust % BITS_PER_UNIT) == 0); gcc_assert ((adjust % BITS_PER_UNIT) == 0);
gcc_assert (*offset != NULL_TREE);
*bitpos += adjust; *bitpos += adjust;
*offset if (*offset == NULL_TREE)
= size_binop (MINUS_EXPR, *offset, size_int (adjust / BITS_PER_UNIT)); *offset = size_int (-adjust / BITS_PER_UNIT);
else
*offset
= size_binop (MINUS_EXPR, *offset, size_int (adjust / BITS_PER_UNIT));
*bitstart = 0; *bitstart = 0;
} }
else else
...@@ -4721,6 +4721,15 @@ expand_assignment (tree to, tree from, bool nontemporal) ...@@ -4721,6 +4721,15 @@ expand_assignment (tree to, tree from, bool nontemporal)
tem = get_inner_reference (to, &bitsize, &bitpos, &offset, &mode1, tem = get_inner_reference (to, &bitsize, &bitpos, &offset, &mode1,
&unsignedp, &volatilep, true); &unsignedp, &volatilep, true);
/* Make sure bitpos is not negative, it can wreak havoc later. */
if (bitpos < 0)
{
gcc_assert (offset == NULL_TREE);
offset = size_int (bitpos >> (BITS_PER_UNIT == 8
? 3 : exact_log2 (BITS_PER_UNIT)));
bitpos &= BITS_PER_UNIT - 1;
}
if (TREE_CODE (to) == COMPONENT_REF if (TREE_CODE (to) == COMPONENT_REF
&& DECL_BIT_FIELD_TYPE (TREE_OPERAND (to, 1))) && DECL_BIT_FIELD_TYPE (TREE_OPERAND (to, 1)))
get_bit_range (&bitregion_start, &bitregion_end, to, &bitpos, &offset); get_bit_range (&bitregion_start, &bitregion_end, to, &bitpos, &offset);
......
2013-11-06 Jakub Jelinek <jakub@redhat.com>
PR middle-end/58970
* gcc.c-torture/compile/pr58970.c: New test.
2013-11-05 Wei Mi <wmi@google.com> 2013-11-05 Wei Mi <wmi@google.com>
PR regression/58985 PR regression/58985
......
/* PR middle-end/58970 */
struct T { int b : 1; };
struct S { struct T t[1]; };
void
foo (int x, struct S *s)
{
if (x == -1)
s->t[x].b = 0;
}
/* PR middle-end/58970 */
struct T { char a : 8; char b : 1; };
struct S { char x; struct T t[1]; };
void
foo (int x, struct S *s)
{
if (x == -1)
s->t[x].b = 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment