Ignore:
Timestamp:
Nov 4, 2004, 1:37:17 AM (21 years ago)
Author:
bird
Message:

Joined the GCC 3.3.5.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gcc/gcc/cp/decl.c

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r1599 r1600  
    148148static void expand_static_init (tree, tree);
    149149static tree next_initializable_field (tree);
     150static bool reshape_init_array (tree, tree, tree *, tree);
    150151static tree reshape_init (tree, tree *);
    151152
     
    82278228}
    82288229
     8230/* Subroutine of reshape_init. Reshape the constructor for an array. INITP
     8231   is the pointer to the old constructor list (to the CONSTRUCTOR_ELTS of
     8232   the CONSTRUCTOR we are processing), while NEW_INIT is the CONSTRUCTOR we
     8233   are building.
     8234   ELT_TYPE is the element type of the array. MAX_INDEX is an INTEGER_CST
     8235   representing the size of the array minus one (the maximum index), or
     8236   NULL_TREE if the array was declared without specifying the size.  */
     8237
     8238static bool
     8239reshape_init_array (tree elt_type, tree max_index,
     8240                    tree *initp, tree new_init)
     8241{
     8242  bool sized_array_p = (max_index != NULL_TREE);
     8243  HOST_WIDE_INT max_index_cst = 0;
     8244  HOST_WIDE_INT index;
     8245
     8246  if (sized_array_p)
     8247    /* HWI is either 32bit or 64bit, so it must be enough to represent the
     8248        array size.  */
     8249    max_index_cst = tree_low_cst (max_index, 1);
     8250
     8251  /* Loop until there are no more initializers.  */
     8252  for (index = 0;
     8253       *initp && (!sized_array_p || index <= max_index_cst);
     8254       ++index)
     8255    {
     8256      tree element_init;
     8257      tree designated_index;
     8258
     8259      element_init = reshape_init (elt_type, initp);
     8260      if (element_init == error_mark_node)
     8261        return false;
     8262      TREE_CHAIN (element_init) = CONSTRUCTOR_ELTS (new_init);
     8263      CONSTRUCTOR_ELTS (new_init) = element_init;
     8264      designated_index = TREE_PURPOSE (element_init);
     8265      if (designated_index)
     8266        {
     8267          if (TREE_CODE (designated_index) != INTEGER_CST)
     8268            abort ();
     8269          if (sized_array_p
     8270              && tree_int_cst_lt (max_index, designated_index))
     8271            {
     8272              error ("Designated initializer `%E' larger than array "
     8273                      "size", designated_index);
     8274              TREE_PURPOSE (element_init) = NULL_TREE;
     8275            }
     8276          else
     8277            index = tree_low_cst (designated_index, 1);
     8278        }
     8279    }
     8280
     8281  return true;
     8282}
     8283
    82298284/* Undo the brace-elision allowed by [dcl.init.aggr] in a
    82308285   brace-enclosed aggregate initializer.
     
    84028457      else if ((TREE_CODE (type) == ARRAY_TYPE)|| (TREE_CODE (type) == VECTOR_TYPE))
    84038458        {
    8404           tree index;
    84058459          tree max_index;
    84068460
     
    84098463          max_index = ((TYPE_DOMAIN (type) && (TREE_CODE (type) == ARRAY_TYPE))
    84108464                       ? array_type_nelts (type) : NULL_TREE);
    8411           /* Loop through the array elements, gathering initializers.  */
    8412           for (index = size_zero_node;
    8413                *initp && (!max_index || !tree_int_cst_lt (max_index, index));
    8414                index = size_binop (PLUS_EXPR, index, size_one_node))
    8415             {
    8416               tree element_init;
    8417 
    8418               element_init = reshape_init (TREE_TYPE (type), initp);
    8419               if (element_init == error_mark_node)
    8420                 return error_mark_node;
    8421               TREE_CHAIN (element_init) = CONSTRUCTOR_ELTS (new_init);
    8422               CONSTRUCTOR_ELTS (new_init) = element_init;
    8423               if (TREE_PURPOSE (element_init))
    8424                 index = convert (sizetype, TREE_PURPOSE (element_init));
    8425             }
     8465          if (!reshape_init_array (TREE_TYPE (type), max_index,
     8466                                   initp, new_init))
     8467            return error_mark_node;
    84268468        }
    84278469      else
Note: See TracChangeset for help on using the changeset viewer.