diff options
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r-- | gcc/gimplify.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c index a4ff3d2..9b34970 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -2706,13 +2706,18 @@ gimplify_init_constructor (tree *expr_p, tree *pre_p, parts in, then generate code for the non-constant parts. */ /* TODO. There's code in cp/typeck.c to do this. */ - num_type_elements = count_type_elements (TREE_TYPE (ctor)); + num_type_elements = count_type_elements (type, true); + /* If count_type_elements could not determine number of type elements + for a constant-sized object, assume clearing is needed. + Don't do this for variable-sized objects, as store_constructor + will ignore the clearing of variable-sized objects. */ + if (num_type_elements < 0 && int_size_in_bytes (type) >= 0) + cleared = true; /* If there are "lots" of zeros, then block clear the object first. */ - if (num_type_elements - num_nonzero_elements > CLEAR_RATIO - && num_nonzero_elements < num_type_elements/4) + else if (num_type_elements - num_nonzero_elements > CLEAR_RATIO + && num_nonzero_elements < num_type_elements/4) cleared = true; - /* ??? This bit ought not be needed. For any element not present in the initializer, we should simply set them to zero. Except we'd need to *find* the elements that are not present, and that |