init = convert (type, nullptr_node);
else if (SCALAR_TYPE_P (type))
init = convert (type, integer_zero_node);
- else if (CLASS_TYPE_P (type))
+ else if (RECORD_OR_UNION_CODE_P (TREE_CODE (type)))
{
tree field;
VEC(constructor_elt,gc) *v = NULL;
have an upper bound of -1. */
if (!tree_int_cst_equal (max_index, integer_minus_one_node))
{
- constructor_elt *ce;
-
- v = VEC_alloc (constructor_elt, gc, 1);
- ce = VEC_quick_push (constructor_elt, v, NULL);
+ 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))
- ce->index = size_zero_node;
+ ce.index = size_zero_node;
else
- ce->index = build2 (RANGE_EXPR, sizetype, size_zero_node,
- max_index);
+ ce.index = build2 (RANGE_EXPR, sizetype, size_zero_node,
+ 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)
+ {
+ v = VEC_alloc (constructor_elt, gc, 1);
+ *VEC_quick_push (constructor_elt, v, NULL) = ce;
+ }
}
/* Build a constructor to contain the initializations. */
have an upper bound of -1. */
if (!tree_int_cst_equal (max_index, integer_minus_one_node))
{
- constructor_elt *ce;
-
- v = VEC_alloc (constructor_elt, gc, 1);
- ce = VEC_quick_push (constructor_elt, v, NULL);
+ 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))
- ce->index = size_zero_node;
+ ce.index = size_zero_node;
else
- ce->index = build2 (RANGE_EXPR, sizetype, size_zero_node,
- max_index);
+ ce.index = build2 (RANGE_EXPR, sizetype, size_zero_node,
+ max_index);
- ce->value = build_value_init (TREE_TYPE (type), complain);
+ ce.value = build_value_init (TREE_TYPE (type), complain);
- if (ce->value == error_mark_node)
- return error_mark_node;
+ if (ce.value)
+ {
+ if (ce.value == error_mark_node)
+ return error_mark_node;
+
+ v = VEC_alloc (constructor_elt, gc, 1);
+ *VEC_quick_push (constructor_elt, v, NULL) = ce;
- /* We shouldn't have gotten here for anything that would need
- non-trivial initialization, and gimplify_init_ctor_preeval
- would need to be fixed to allow it. */
- gcc_assert (TREE_CODE (ce->value) != TARGET_EXPR
- && TREE_CODE (ce->value) != AGGR_INIT_EXPR);
+ /* We shouldn't have gotten here for anything that would need
+ non-trivial initialization, and gimplify_init_ctor_preeval
+ would need to be fixed to allow it. */
+ gcc_assert (TREE_CODE (ce.value) != TARGET_EXPR
+ && TREE_CODE (ce.value) != AGGR_INIT_EXPR);
+ }
}
/* Build a constructor to contain the initializations. */
that's value-initialization. */
if (init == void_type_node)
{
- /* If no user-provided ctor, we need to zero out the object. */
- if (!type_has_user_provided_constructor (type))
+ /* If the type has data but no user-provided ctor, we need to zero
+ out the object. */
+ if (!type_has_user_provided_constructor (type)
+ && !is_really_empty_class (type))
{
tree field_size = NULL_TREE;
if (exp != true_exp && CLASSTYPE_AS_BASE (type) != type)
orig_placement = make_tree_vector_copy (*placement);
orig_nelts = nelts;
- orig_init = make_tree_vector_copy (*init);
+ if (*init)
+ orig_init = make_tree_vector_copy (*init);
make_args_non_dependent (*placement);
if (nelts)
if (TREE_CODE (atype) == ARRAY_TYPE && TYPE_DOMAIN (atype))
maxindex = array_type_nelts (atype);
- if (maxindex == NULL_TREE || maxindex == error_mark_node
- || integer_all_onesp (maxindex))
+ if (maxindex == NULL_TREE || maxindex == error_mark_node)
return error_mark_node;
if (explicit_value_init_p)
else
{
if (do_static_init)
- CONSTRUCTOR_APPEND_ELT (new_vec, field,
- build_zero_init (TREE_TYPE (e),
- NULL_TREE, true));
+ {
+ tree value = build_zero_init (TREE_TYPE (e), NULL_TREE,
+ true);
+ if (value)
+ CONSTRUCTOR_APPEND_ELT (new_vec, field, value);
+ }
saw_non_const = true;
}
}
if (TREE_CODE (type) == ARRAY_TYPE)
m = cp_build_binary_op (input_location,
MULT_EXPR, m,
- array_type_nelts_total (type),
+ /* Force signed arithmetic. */
+ convert (TREE_TYPE (m),
+ array_type_nelts_total (type)),
complain);
finish_cleanup_try_block (try_block);