summaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-21 09:15:29 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-21 09:15:29 +0000
commit2569a1bed4c889254f528fdc227fad12430a8dec (patch)
tree2f19dd655a5b6d52dc032012f1972b9a63e632e4 /gcc/fold-const.c
parent0023616d66a0e62e41b5f191d992d2a77c39ff9d (diff)
downloadgcc-2569a1bed4c889254f528fdc227fad12430a8dec.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@83429 138bc75d-0d04-0410-961f-82ee72b054a4
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 220d1af95ac..517d5508b95 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);