aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2004-06-21 02:15:29 -0700
committerRichard Henderson <rth@gcc.gnu.org>2004-06-21 02:15:29 -0700
commit3a5b9284da6acc309118a04dcba3a1cbca2ecdd4 (patch)
tree2f19dd655a5b6d52dc032012f1972b9a63e632e4 /gcc/fold-const.c
parent2c486ea78cfcbd4b05c7845db23647fe2bf61d6d (diff)
downloadgcc-3a5b9284da6acc309118a04dcba3a1cbca2ecdd4.zip
gcc-3a5b9284da6acc309118a04dcba3a1cbca2ecdd4.tar.gz
gcc-3a5b9284da6acc309118a04dcba3a1cbca2ecdd4.tar.bz2
c-common.c (verify_sequence_points): Export.
* c-common.c (verify_sequence_points): Export. (c_expand_expr_stmt): Move to c-typeck.c. * c-common.h (c_expand_expr_stmt): Remove. (verify_sequence_points): Declare. * c-mudflap.c (mflang_flush_calls): Use c_finish_expr_stmt. * c-parse.in (for_init_stmt, stmt): Likewise. * c-tree.h (c_finish_expr_stmt): Declare. (c_tree_expr_nonnegative_p): Remove. * c-typeck.c (c_tree_expr_nonnegative_p): Remove. (build_conditional_expr, build_binary_op): Use tree_expr_nonnegative_p. (emit_side_effect_warnings): New. (c_finish_expr_stmt): Rename from c_expand_expr_stmt. Use it. (c_finish_stmt_expr): Work without EXPR_STMT. Handle eh regions. Use emit_side_effect_warnings. (push_cleanup): Copy STATEMENT_LIST_STMT_EXPR. * fold-const.c (tree_expr_nonnegative_p): Handle TARGET_EXPR. * gimplify.c (gimplify_modify_expr): Don't discard TARGET_EXPR with void initializer. (gimplify_target_expr): Handle void BIND_EXPR initializer. * tree-inline.c (estimate_num_insns_1): Fix type lookup for INIT_EXPR and MODIFY_EXPR. * objc/objc-act.c (build_module_descriptor): Use add_stmt instead of c_expand_expr_stmt. cp/ * semantics.c (finish_expr_stmt): Call verify_sequence_points. testsuite/ * gcc.dg/tree-ssa/20030714-1.c: Rename variables to avoid merging && to BIT_FIELD_REF. From-SVN: r83429
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 220d1af..517d550 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -9267,6 +9267,37 @@ tree_expr_nonnegative_p (tree t)
case RTL_EXPR:
return rtl_expr_nonnegative_p (RTL_EXPR_RTL (t));
+ case TARGET_EXPR:
+ {
+ tree temp = TARGET_EXPR_SLOT (t);
+ t = TARGET_EXPR_INITIAL (t);
+
+ /* If the initializer is non-void, then it's a normal expression
+ that will be assigned to the slot. */
+ if (!VOID_TYPE_P (t))
+ return tree_expr_nonnegative_p (t);
+
+ /* Otherwise, the initializer sets the slot in some way. One common
+ way is an assignment statement at the end of the initializer. */
+ while (1)
+ {
+ if (TREE_CODE (t) == BIND_EXPR)
+ t = expr_last (BIND_EXPR_BODY (t));
+ else if (TREE_CODE (t) == TRY_FINALLY_EXPR
+ || TREE_CODE (t) == TRY_CATCH_EXPR)
+ t = expr_last (TREE_OPERAND (t, 0));
+ else if (TREE_CODE (t) == STATEMENT_LIST)
+ t = expr_last (t);
+ else
+ break;
+ }
+ if (TREE_CODE (t) == MODIFY_EXPR
+ && TREE_OPERAND (t, 0) == temp)
+ return tree_expr_nonnegative_p (TREE_OPERAND (t, 1));
+
+ return 0;
+ }
+
case CALL_EXPR:
{
tree fndecl = get_callee_fndecl (t);