Commit 72aeff7c by Kaz Kojima

re PR middle-end/28160 (Bogus "size of array 'foo' is too large" error with -mms-bitfields)

	PR middle-end/28160
	* stor-layout.c (place_field): Take the bit field with
	an excessive size into account in the ms-bitfiled case.

	PR middle-end/28161
	* stor-layout.c (place_field): Use DECL_BIT_FIELD_TYPE of
	the previous bit field.

From-SVN: r115464
parent 5cd8e123
2006-07-15 Kaz Kojima <kkojima@gcc.gnu.org>
PR middle-end/28160
* stor-layout.c (place_field): Take the bit field with
an excessive size into account in the ms-bitfiled case.
PR middle-end/28161
* stor-layout.c (place_field): Use DECL_BIT_FIELD_TYPE of
the previous bit field.
2006-07-14 Eliot Dresselhaus <eliot@sonic.net> 2006-07-14 Eliot Dresselhaus <eliot@sonic.net>
PR target/27287 PR target/27287
......
...@@ -1022,6 +1022,7 @@ place_field (record_layout_info rli, tree field) ...@@ -1022,6 +1022,7 @@ place_field (record_layout_info rli, tree field)
if (targetm.ms_bitfield_layout_p (rli->t)) if (targetm.ms_bitfield_layout_p (rli->t))
{ {
tree prev_saved = rli->prev_field; tree prev_saved = rli->prev_field;
tree prev_type = prev_saved ? DECL_BIT_FIELD_TYPE (prev_saved) : NULL;
/* This is a bitfield if it exists. */ /* This is a bitfield if it exists. */
if (rli->prev_field) if (rli->prev_field)
...@@ -1037,8 +1038,7 @@ place_field (record_layout_info rli, tree field) ...@@ -1037,8 +1038,7 @@ place_field (record_layout_info rli, tree field)
&& !integer_zerop (DECL_SIZE (rli->prev_field)) && !integer_zerop (DECL_SIZE (rli->prev_field))
&& host_integerp (DECL_SIZE (rli->prev_field), 0) && host_integerp (DECL_SIZE (rli->prev_field), 0)
&& host_integerp (TYPE_SIZE (type), 0) && host_integerp (TYPE_SIZE (type), 0)
&& simple_cst_equal (TYPE_SIZE (type), && simple_cst_equal (TYPE_SIZE (type), TYPE_SIZE (prev_type)))
TYPE_SIZE (TREE_TYPE (rli->prev_field))))
{ {
/* We're in the middle of a run of equal type size fields; make /* We're in the middle of a run of equal type size fields; make
sure we realign if we run out of bits. (Not decl size, sure we realign if we run out of bits. (Not decl size,
...@@ -1047,17 +1047,20 @@ place_field (record_layout_info rli, tree field) ...@@ -1047,17 +1047,20 @@ place_field (record_layout_info rli, tree field)
if (rli->remaining_in_alignment < bitsize) if (rli->remaining_in_alignment < bitsize)
{ {
HOST_WIDE_INT typesize = tree_low_cst (TYPE_SIZE (type), 1);
/* out of bits; bump up to next 'word'. */ /* out of bits; bump up to next 'word'. */
rli->offset = DECL_FIELD_OFFSET (rli->prev_field);
rli->bitpos rli->bitpos
= size_binop (PLUS_EXPR, TYPE_SIZE (type), = size_binop (PLUS_EXPR, rli->bitpos,
DECL_FIELD_BIT_OFFSET (rli->prev_field)); bitsize_int (rli->remaining_in_alignment));
rli->prev_field = field; rli->prev_field = field;
rli->remaining_in_alignment if (typesize < bitsize)
= tree_low_cst (TYPE_SIZE (type), 1); rli->remaining_in_alignment = 0;
else
rli->remaining_in_alignment = typesize - bitsize;
} }
else
rli->remaining_in_alignment -= bitsize; rli->remaining_in_alignment -= bitsize;
} }
else else
{ {
...@@ -1105,8 +1108,7 @@ place_field (record_layout_info rli, tree field) ...@@ -1105,8 +1108,7 @@ place_field (record_layout_info rli, tree field)
if (!DECL_BIT_FIELD_TYPE (field) if (!DECL_BIT_FIELD_TYPE (field)
|| (prev_saved != NULL || (prev_saved != NULL
? !simple_cst_equal (TYPE_SIZE (type), ? !simple_cst_equal (TYPE_SIZE (type), TYPE_SIZE (prev_type))
TYPE_SIZE (TREE_TYPE (prev_saved)))
: !integer_zerop (DECL_SIZE (field)) )) : !integer_zerop (DECL_SIZE (field)) ))
{ {
/* Never smaller than a byte for compatibility. */ /* Never smaller than a byte for compatibility. */
...@@ -1119,9 +1121,16 @@ place_field (record_layout_info rli, tree field) ...@@ -1119,9 +1121,16 @@ place_field (record_layout_info rli, tree field)
if (DECL_SIZE (field) != NULL if (DECL_SIZE (field) != NULL
&& host_integerp (TYPE_SIZE (TREE_TYPE (field)), 0) && host_integerp (TYPE_SIZE (TREE_TYPE (field)), 0)
&& host_integerp (DECL_SIZE (field), 0)) && host_integerp (DECL_SIZE (field), 0))
rli->remaining_in_alignment {
= tree_low_cst (TYPE_SIZE (TREE_TYPE(field)), 1) HOST_WIDE_INT bitsize = tree_low_cst (DECL_SIZE (field), 1);
- tree_low_cst (DECL_SIZE (field), 1); HOST_WIDE_INT typesize
= tree_low_cst (TYPE_SIZE (TREE_TYPE (field)), 1);
if (typesize < bitsize)
rli->remaining_in_alignment = 0;
else
rli->remaining_in_alignment = typesize - bitsize;
}
/* Now align (conventionally) for the new type. */ /* Now align (conventionally) for the new type. */
type_align = TYPE_ALIGN (TREE_TYPE (field)); type_align = TYPE_ALIGN (TREE_TYPE (field));
......
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