/* Iterate over the array elements, building initializations. */
if (nelts)
- max_index = fold_build2_loc (input_location,
- MINUS_EXPR, TREE_TYPE (nelts),
- nelts, integer_one_node);
+ max_index = fold_build2_loc (input_location, MINUS_EXPR,
+ TREE_TYPE (nelts), nelts,
+ build_one_cst (TREE_TYPE (nelts)));
+ /* Treat flexible array members like [0] arrays. */
+ else if (TYPE_DOMAIN (type) == NULL_TREE)
+ max_index = build_minus_one_cst (sizetype);
else
max_index = array_type_nelts (type);
/* A zero-sized array, which is accepted as an extension, will
have an upper bound of -1. */
- if (!tree_int_cst_equal (max_index, integer_minus_one_node))
+ if (!integer_minus_onep (max_index))
{
constructor_elt ce;
/* If this is a one element array, we just use a regular init. */
- if (tree_int_cst_equal (size_zero_node, max_index))
+ if (integer_zerop (max_index))
ce.index = size_zero_node;
else
ce.index = build2 (RANGE_EXPR, sizetype, size_zero_node,
- max_index);
+ max_index);
- ce.value = build_zero_init_1 (TREE_TYPE (type),
- /*nelts=*/NULL_TREE,
- static_storage_p, NULL_TREE);
+ ce.value = build_zero_init_1 (TREE_TYPE (type), /*nelts=*/NULL_TREE,
+ static_storage_p, NULL_TREE);
if (ce.value)
{
vec_alloc (v, 1);