2004-01-16 Mark Mitchell <mark@codesourcery.com>
+ PR c++/13574
+ * decl.c (compute_array_index_type): Fix grammar in comment.
+ * init.c (build_zero_init): Handle zero-sized arrays correctly.
+
PR c++/13178
* call.c (name_as_c_string): Print conversion operator names
correctly.
error ("size of array is negative");
size = integer_one_node;
}
- /* Except that an extension we allow zero-sized arrays. We
- always allow them in system headers because glibc uses
- them. */
+ /* As an extension we allow zero-sized arrays. We always allow
+ them in system headers because glibc uses them. */
else if (integer_zerop (size) && pedantic && !in_system_header)
{
if (name)
max_index = nelts ? nelts : array_type_nelts (type);
my_friendly_assert (TREE_CODE (max_index) == INTEGER_CST, 20030618);
- for (index = size_zero_node;
- !tree_int_cst_lt (max_index, index);
- index = size_binop (PLUS_EXPR, index, size_one_node))
- inits = tree_cons (index,
- build_zero_init (TREE_TYPE (type),
- /*nelts=*/NULL_TREE,
- static_storage_p),
- inits);
+ /* 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))
+ for (index = size_zero_node;
+ !tree_int_cst_lt (max_index, index);
+ index = size_binop (PLUS_EXPR, index, size_one_node))
+ inits = tree_cons (index,
+ build_zero_init (TREE_TYPE (type),
+ /*nelts=*/NULL_TREE,
+ static_storage_p),
+ inits);
CONSTRUCTOR_ELTS (init) = nreverse (inits);
}
else if (TREE_CODE (type) == REFERENCE_TYPE)