From e196b22163a6c1a723648b3f09501ebd586fa1c0 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Mon, 13 Sep 2010 18:37:06 +0200 Subject: tree.c (build_zero_cst): New. * tree.c (build_zero_cst): New. * tree.h (build_zero_cst): Declare. * tree-ssa-ccp.c (get_constant_value): Accept general operands. (get_base_constructor): Break out from ... (fold_const_aggregate_ref): Here; handle empty constructors. * gcc.dg/torture/pr23821.c: Drop static keyword. * gcc.dg/tree-ssa/loop-19.c: Likewise. * gcc.dg/tree-ssa/foldconst-4.c: New. From-SVN: r164250 --- gcc/tree.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'gcc/tree.c') diff --git a/gcc/tree.c b/gcc/tree.c index c20d3b6c5ce..fd593e39ebd 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -1583,6 +1583,18 @@ build_one_cst (tree type) } } +/* Build 0 constant of type TYPE. This is used by constructor folding and thus + the constant should correspond zero in memory representation. */ + +tree +build_zero_cst (tree type) +{ + if (!AGGREGATE_TYPE_P (type)) + return fold_convert (type, integer_zero_node); + return build_constructor (type, NULL); +} + + /* Build a BINFO with LEN language slots. */ tree -- cgit v1.2.1