diff options
author | Richard Kenner <kenner@vlsi1.ultra.nyu.edu> | 2001-01-04 20:58:20 +0000 |
---|---|---|
committer | Richard Kenner <kenner@gcc.gnu.org> | 2001-01-04 15:58:20 -0500 |
commit | bf1aaf0ac6dc0ea6019b0181211c2f0316526aec (patch) | |
tree | 35b7132cf78a1659f1ec7f56c25e7dfd251387c8 | |
parent | ceebdb0980bee33cbd7b08dcd350f4faa7634f27 (diff) | |
download | gcc-bf1aaf0ac6dc0ea6019b0181211c2f0316526aec.zip gcc-bf1aaf0ac6dc0ea6019b0181211c2f0316526aec.tar.gz gcc-bf1aaf0ac6dc0ea6019b0181211c2f0316526aec.tar.bz2 |
varasm.c (output_constructor): Use HOST_WIDE_INT for sizes.
* varasm.c (output_constructor): Use HOST_WIDE_INT for sizes.
Only call array_size_for_constructor if last field and array type
with no upper bound.
From-SVN: r38691
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/varasm.c | 23 |
2 files changed, 17 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6a2c343..d37423b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +Thu Jan 4 15:54:05 2001 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> + + * varasm.c (output_constructor): Use HOST_WIDE_INT for sizes. + Only call array_size_for_constructor if last field and array type + with no upper bound. + 2001-01-04 Philip Blundell <philb@gnu.org> * config/arm/arm.c (arm_gen_constant): Prefer to emit constants diff --git a/gcc/varasm.c b/gcc/varasm.c index b87d9be..4dbbbfb 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -4549,7 +4549,7 @@ output_constructor (exp, size) if (index && TREE_CODE (index) == RANGE_EXPR) { - register int fieldsize + unsigned HOST_WIDE_INT fieldsize = int_size_in_bytes (TREE_TYPE (type)); HOST_WIDE_INT lo_index = tree_low_cst (TREE_OPERAND (index, 0), 0); HOST_WIDE_INT hi_index = tree_low_cst (TREE_OPERAND (index, 1), 0); @@ -4571,7 +4571,7 @@ output_constructor (exp, size) { /* An element that is not a bit-field. */ - register int fieldsize; + unsigned HOST_WIDE_INT fieldsize; /* Since this structure is static, we know the positions are constant. */ HOST_WIDE_INT pos = field ? int_byte_position (field) : 0; @@ -4607,17 +4607,16 @@ output_constructor (exp, size) /* Determine size this element should occupy. */ if (field) { - if (DECL_SIZE_UNIT (field) - && ! integer_zerop (DECL_SIZE_UNIT (field))) - fieldsize = tree_low_cst (DECL_SIZE_UNIT (field), 1); - else if (TREE_CODE (TREE_TYPE (field)) == ARRAY_TYPE) - { - /* If DECL_SIZE is not set or is zero, then this must be - an array of unspecified length. The initialized value - must be a CONSTRUCTOR, and we take the length from the - last initialized element. */ + /* If the last field is an array with an unspecified upper + bound, the initializer determines the size. */ + if (TREE_CHAIN (field) == 0 + && TREE_CODE (TREE_TYPE (field)) == ARRAY_TYPE + && TYPE_DOMAIN (TREE_TYPE (field)) != 0 + && TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (field))) == 0) fieldsize = array_size_for_constructor (val); - } + else if (DECL_SIZE_UNIT (field) + && host_integerp (DECL_SIZE_UNIT (field), 1)) + fieldsize = tree_low_cst (DECL_SIZE_UNIT (field), 1); else fieldsize = 0; } |