Commit b5ff0f70 by Richard Kenner

(output_init_elements): Use FIELD instead of constructor_fields when doing alignment and sizing.

(output_init_elements): Use FIELD instead of constructor_fields when
doing alignment and sizing.
(output_pending_init_elements): Don't blow up when writing other than
first field put haven't written anything yet.  Update
constructor_bit_index when we emit a skip.

From-SVN: r6414
parent 16411ea6
...@@ -5645,7 +5645,7 @@ output_init_element (value, type, field, pending) ...@@ -5645,7 +5645,7 @@ output_init_element (value, type, field, pending)
{ {
/* Advance to offset of this element. */ /* Advance to offset of this element. */
if (! tree_int_cst_equal (constructor_bit_index, if (! tree_int_cst_equal (constructor_bit_index,
DECL_FIELD_BITPOS (constructor_fields))) DECL_FIELD_BITPOS (field)))
{ {
int next = (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field)) int next = (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field))
/ BITS_PER_UNIT); / BITS_PER_UNIT);
...@@ -5663,9 +5663,8 @@ output_init_element (value, type, field, pending) ...@@ -5663,9 +5663,8 @@ output_init_element (value, type, field, pending)
if (TREE_CODE (constructor_type) == RECORD_TYPE if (TREE_CODE (constructor_type) == RECORD_TYPE
|| TREE_CODE (constructor_type) == UNION_TYPE) || TREE_CODE (constructor_type) == UNION_TYPE)
{ {
tree temp = size_binop (PLUS_EXPR, tree temp = size_binop (PLUS_EXPR, DECL_FIELD_BITPOS (field),
DECL_FIELD_BITPOS (constructor_fields), DECL_SIZE (field));
DECL_SIZE (constructor_fields));
TREE_INT_CST_LOW (constructor_bit_index) TREE_INT_CST_LOW (constructor_bit_index)
= TREE_INT_CST_LOW (temp); = TREE_INT_CST_LOW (temp);
TREE_INT_CST_HIGH (constructor_bit_index) TREE_INT_CST_HIGH (constructor_bit_index)
...@@ -5777,20 +5776,30 @@ output_pending_init_elements (all) ...@@ -5777,20 +5776,30 @@ output_pending_init_elements (all)
if (TREE_CODE (constructor_type) == RECORD_TYPE if (TREE_CODE (constructor_type) == RECORD_TYPE
|| TREE_CODE (constructor_type) == UNION_TYPE) || TREE_CODE (constructor_type) == UNION_TYPE)
{ {
/* Find the last field written out. */ /* Find the last field written out, if any. */
for (tail = TYPE_FIELDS (constructor_type); tail; for (tail = TYPE_FIELDS (constructor_type); tail;
tail = TREE_CHAIN (tail)) tail = TREE_CHAIN (tail))
if (TREE_CHAIN (tail) == constructor_unfilled_fields) if (TREE_CHAIN (tail) == constructor_unfilled_fields)
break; break;
/* Find the offset of the end of that field. */
filled = size_binop (CEIL_DIV_EXPR, if (tail)
size_binop (PLUS_EXPR, /* Find the offset of the end of that field. */
DECL_FIELD_BITPOS (tail), filled = size_binop (CEIL_DIV_EXPR,
DECL_SIZE (tail)), size_binop (PLUS_EXPR,
size_int (BITS_PER_UNIT)); DECL_FIELD_BITPOS (tail),
DECL_SIZE (tail)),
size_int (BITS_PER_UNIT));
else
filled = size_int (0);
nextpos_tree = size_binop (CEIL_DIV_EXPR, nextpos_tree = size_binop (CEIL_DIV_EXPR,
DECL_FIELD_BITPOS (next), DECL_FIELD_BITPOS (next),
size_int (BITS_PER_UNIT)); size_int (BITS_PER_UNIT));
TREE_INT_CST_HIGH (constructor_bit_index)
= TREE_INT_CST_HIGH (DECL_FIELD_BITPOS (next));
TREE_INT_CST_LOW (constructor_bit_index)
= TREE_INT_CST_LOW (DECL_FIELD_BITPOS (next));
constructor_unfilled_fields = next; constructor_unfilled_fields = next;
} }
else if (TREE_CODE (constructor_type) == ARRAY_TYPE) else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
......
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