Commit 3181cbfd by Richard Stallman

(output_constructor): Handle index value in

the TREE_PURPOSE, for array constructors.

From-SVN: r5314
parent d4c89139
...@@ -3040,25 +3040,37 @@ output_constructor (exp, size) ...@@ -3040,25 +3040,37 @@ output_constructor (exp, size)
field = field ? TREE_CHAIN (field) : 0) field = field ? TREE_CHAIN (field) : 0)
{ {
tree val = TREE_VALUE (link); tree val = TREE_VALUE (link);
tree index = 0;
/* the element in a union constructor specifies the proper field. */ /* the element in a union constructor specifies the proper field. */
if (TREE_PURPOSE (link) != 0)
if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
|| TREE_CODE (TREE_TYPE (exp)) == UNION_TYPE)
field = TREE_PURPOSE (link); field = TREE_PURPOSE (link);
if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
index = TREE_PURPOSE (link);
/* Eliminate the marker that makes a cast not be an lvalue. */ /* Eliminate the marker that makes a cast not be an lvalue. */
if (val != 0) if (val != 0)
STRIP_NOPS (val); STRIP_NOPS (val);
if (field == 0 || !DECL_BIT_FIELD (field)) if (field == 0 || !DECL_BIT_FIELD (field))
{ {
/* An element that is not a bit-field. */
register int fieldsize; register int fieldsize;
/* Since this structure is static, /* Since this structure is static,
we know the positions are constant. */ we know the positions are constant. */
int bitpos = (field ? (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field)) int bitpos = (field ? (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field))
/ BITS_PER_UNIT) / BITS_PER_UNIT)
: 0); : 0);
if (index != 0)
bitpos = (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (val)))
/ BITS_PER_UNIT
* TREE_INT_CST_LOW (index));
/* An element that is not a bit-field. /* Output any buffered-up bit-fields preceding this element. */
Output any buffered-up bit-fields preceding it. */
if (byte_buffer_in_use) if (byte_buffer_in_use)
{ {
ASM_OUTPUT_BYTE (asm_out_file, byte); ASM_OUTPUT_BYTE (asm_out_file, byte);
...@@ -3069,7 +3081,7 @@ output_constructor (exp, size) ...@@ -3069,7 +3081,7 @@ output_constructor (exp, size)
/* Advance to offset of this element. /* Advance to offset of this element.
Note no alignment needed in an array, since that is guaranteed Note no alignment needed in an array, since that is guaranteed
if each element has the proper size. */ if each element has the proper size. */
if (field != 0 && bitpos != total_bytes) if ((field != 0 || index != 0) && bitpos != total_bytes)
{ {
assemble_zeros (bitpos - total_bytes); assemble_zeros (bitpos - total_bytes);
total_bytes = bitpos; total_bytes = bitpos;
......
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