From: Richard Kenner Date: Thu, 4 Jan 2001 20:58:20 +0000 (+0000) Subject: varasm.c (output_constructor): Use HOST_WIDE_INT for sizes. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bf1aaf0ac6dc0ea6019b0181211c2f0316526aec;p=gcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6a2c343d36c..d37423bc50c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +Thu Jan 4 15:54:05 2001 Richard Kenner + + * 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 * config/arm/arm.c (arm_gen_constant): Prefer to emit constants diff --git a/gcc/varasm.c b/gcc/varasm.c index b87d9beeaca..4dbbbfbbff8 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; }