diff options
author | rms <rms@138bc75d-0d04-0410-961f-82ee72b054a4> | 1993-09-13 18:13:56 +0000 |
---|---|---|
committer | rms <rms@138bc75d-0d04-0410-961f-82ee72b054a4> | 1993-09-13 18:13:56 +0000 |
commit | ff1c73fe262294867a2d408257f5aa6333a9d667 (patch) | |
tree | a76f8db0bcda564aeaa95a33318edd8c53eac2ac /gcc/varasm.c | |
parent | ecef77f66009e83136a42fad8e6429a5ce708f39 (diff) | |
download | gcc-ff1c73fe262294867a2d408257f5aa6333a9d667.tar.gz |
(output_constructor): Handle index value in
the TREE_PURPOSE, for array constructors.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@5314 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r-- | gcc/varasm.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c index e11787665b3..ea3fbb2a211 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -3040,25 +3040,37 @@ output_constructor (exp, size) field = field ? TREE_CHAIN (field) : 0) { tree val = TREE_VALUE (link); + tree index = 0; + /* 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); + if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE) + index = TREE_PURPOSE (link); + /* Eliminate the marker that makes a cast not be an lvalue. */ if (val != 0) STRIP_NOPS (val); if (field == 0 || !DECL_BIT_FIELD (field)) { + /* An element that is not a bit-field. */ + register int fieldsize; /* Since this structure is static, we know the positions are constant. */ int bitpos = (field ? (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field)) / BITS_PER_UNIT) : 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 it. */ + /* Output any buffered-up bit-fields preceding this element. */ if (byte_buffer_in_use) { ASM_OUTPUT_BYTE (asm_out_file, byte); @@ -3069,7 +3081,7 @@ output_constructor (exp, size) /* Advance to offset of this element. Note no alignment needed in an array, since that is guaranteed 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); total_bytes = bitpos; |