aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2010-04-12 10:00:13 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2010-04-12 10:00:13 +0000
commit675c873bfe795ff94288f31c2735254443d3754b (patch)
tree47f2f8e659d1353465936d33a9982cdbaddb3f3b /gcc/expr.c
parent3fc20697523443ed885f701923160ea22a19be62 (diff)
downloadgcc-675c873bfe795ff94288f31c2735254443d3754b.zip
gcc-675c873bfe795ff94288f31c2735254443d3754b.tar.gz
gcc-675c873bfe795ff94288f31c2735254443d3754b.tar.bz2
expr.c (categorize_ctor_elements_1): Properly count sub-elements of non-constant aggregate elements.
* expr.c (categorize_ctor_elements_1): Properly count sub-elements of non-constant aggregate elements. * gimplify.c (gimplify_init_constructor): Do not pre-evaluate if this is a real initialization. From-SVN: r158219
Diffstat (limited to 'gcc/expr.c')
-rw-r--r--gcc/expr.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/gcc/expr.c b/gcc/expr.c
index f5de2ae..930ee98 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -4861,9 +4861,8 @@ categorize_ctor_elements_1 (const_tree ctor, HOST_WIDE_INT *p_nz_elts,
FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (ctor), idx, purpose, value)
{
- HOST_WIDE_INT mult;
+ HOST_WIDE_INT mult = 1;
- mult = 1;
if (TREE_CODE (purpose) == RANGE_EXPR)
{
tree lo_index = TREE_OPERAND (purpose, 0);
@@ -4925,12 +4924,17 @@ categorize_ctor_elements_1 (const_tree ctor, HOST_WIDE_INT *p_nz_elts,
break;
default:
- nz_elts += mult;
- elt_count += mult;
+ {
+ HOST_WIDE_INT tc = count_type_elements (TREE_TYPE (value), true);
+ if (tc < 1)
+ tc = 1;
+ nz_elts += mult * tc;
+ elt_count += mult * tc;
- if (const_from_elts_p && const_p)
- const_p = initializer_constant_valid_p (value, TREE_TYPE (value))
- != NULL_TREE;
+ if (const_from_elts_p && const_p)
+ const_p = initializer_constant_valid_p (value, TREE_TYPE (value))
+ != NULL_TREE;
+ }
break;
}
}