if (overflow || wi::gtu_p (inner_size, max_size))
{
if (complain & tf_error)
- error ("size of array is too large");
+ {
+ cst_size_error error;
+ if (overflow)
+ error = cst_size_overflow;
+ else
+ {
+ error = cst_size_too_big;
+ size = size_binop (MULT_EXPR, size,
+ wide_int_to_tree (sizetype,
+ inner_nelts_count));
+ size = cp_fully_fold (size);
+ }
+ invalid_array_size_error (input_location, error, size,
+ /*name=*/NULL_TREE);
+ }
return error_mark_node;
}
isn't explicitly stated but it's enforced anyway -- see
grokdeclarator in cp/decl.c). */
if (complain & tf_error)
- error ("size of array is too large");
+ {
+ size = cp_fully_fold (size);
+ invalid_array_size_error (input_location, cst_size_too_big,
+ size, NULL_TREE);
+ }
return error_mark_node;
}
}
less than zero. ... If the expression is a constant expression,
the program is ill-fomed. */
if (TREE_CODE (cst_nelts) == INTEGER_CST
- && tree_int_cst_sgn (cst_nelts) == -1)
- {
- if (complain & tf_error)
- error ("size of array is negative");
- return error_mark_node;
- }
+ && !valid_array_size_p (input_location, cst_nelts, NULL_TREE,
+ complain & tf_error))
+ return error_mark_node;
nelts = mark_rvalue_use (nelts);
nelts = cp_save_expr (cp_convert (sizetype, nelts, complain));