This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Zero-length array stuff
- To: gcc-patches at gcc dot gnu dot org
- Subject: Zero-length array stuff
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- Date: Thu, 4 Jan 01 15:59:44 EST
This came out of the discussion on the topic today. Tested on Alpha.
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.
*** varasm.c 2001/01/04 01:14:14 1.151
--- varasm.c 2001/01/04 20:51:22
*************** output_constructor (exp, size)
*** 4550,4554 ****
if (index && TREE_CODE (index) == RANGE_EXPR)
{
! register int fieldsize
= int_size_in_bytes (TREE_TYPE (type));
HOST_WIDE_INT lo_index = tree_low_cst (TREE_OPERAND (index, 0), 0);
--- 4550,4554 ----
if (index && TREE_CODE (index) == RANGE_EXPR)
{
! 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);
*************** output_constructor (exp, size)
*** 4572,4576 ****
/* An element that is not a bit-field. */
! register int fieldsize;
/* Since this structure is static,
we know the positions are constant. */
--- 4572,4576 ----
/* An element that is not a bit-field. */
! unsigned HOST_WIDE_INT fieldsize;
/* Since this structure is static,
we know the positions are constant. */
*************** output_constructor (exp, size)
*** 4608,4622 ****
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. */
fieldsize = array_size_for_constructor (val);
! }
else
fieldsize = 0;
--- 4608,4621 ----
if (field)
{
! /* 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;