From c506ca222b67f823e968193b4b1c7f4f5d814062 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Sun, 14 Nov 1999 05:04:19 +0000 Subject: [PATCH] call.c (build_conditional_expr): Use build_target_expr_with_type. * call.c (build_conditional_expr): Use build_target_expr_with_type. (convert_like): Likewise. (build_over_call): Likewise. * cp-tree.h (build_target_expr): Remove. (build_target_expr_with_type): New function. * cvt.c (build_up_reference): Use get_target_expr. * decl.c (build_target_expr): Move to ... * tree.c (build_target_expr): Here. Make it static. (build_target_expr_with_type): New function. Set DECL_CONTEXT on the temporary VAR_DECLs. (get_target_expr): Use it. From-SVN: r30524 --- gcc/cp/ChangeLog | 14 ++++++++++++++ gcc/cp/call.c | 17 +++-------------- gcc/cp/cp-tree.h | 2 +- gcc/cp/cvt.c | 6 +----- gcc/cp/decl.c | 20 -------------------- gcc/cp/tree.c | 39 ++++++++++++++++++++++++++++++++++++--- 6 files changed, 55 insertions(+), 43 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8bd88f372e5..da62559c9aa 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,17 @@ +1999-11-13 Mark Mitchell + + * call.c (build_conditional_expr): Use build_target_expr_with_type. + (convert_like): Likewise. + (build_over_call): Likewise. + * cp-tree.h (build_target_expr): Remove. + (build_target_expr_with_type): New function. + * cvt.c (build_up_reference): Use get_target_expr. + * decl.c (build_target_expr): Move to ... + * tree.c (build_target_expr): Here. Make it static. + (build_target_expr_with_type): New function. Set DECL_CONTEXT on + the temporary VAR_DECLs. + (get_target_expr): Use it. + 1999-11-13 Jason Merrill * decl.c (duplicate_decls): Propagate DECL_DEFER_OUTPUT. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 38ce371d93a..ee127435dc9 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -3074,11 +3074,7 @@ build_conditional_expr (arg1, arg2, arg3) ?: expression. We used to check for TARGET_EXPRs here, but now we sometimes wrap them in NOP_EXPRs so the test would fail. */ if (!lvalue_p && IS_AGGR_TYPE (result_type)) - { - tree slot = build (VAR_DECL, result_type); - layout_decl (slot, 0); - result = build_target_expr (slot, result); - } + result = build_target_expr_with_type (result, result_type); /* If this expression is an rvalue, but might be mistaken for an lvalue, we must add a NON_LVALUE_EXPR. */ @@ -3743,10 +3739,7 @@ convert_like (convs, expr) if (NEED_TEMPORARY_P (convs)) { tree type = TREE_TYPE (TREE_OPERAND (convs, 0)); - tree slot = build_decl (VAR_DECL, NULL_TREE, type); - DECL_ARTIFICIAL (slot) = 1; - expr = build_target_expr (slot, expr); - TREE_SIDE_EFFECTS (expr) = 1; + expr = build_target_expr_with_type (expr, type); } /* Take the address of the thing to which we will bind the @@ -4074,11 +4067,7 @@ build_over_call (cand, args, flags) if (! real_lvalue_p (arg)) return arg; else if (TYPE_HAS_TRIVIAL_INIT_REF (DECL_CONTEXT (fn))) - { - val = build_decl (VAR_DECL, NULL_TREE, DECL_CONTEXT (fn)); - val = build_target_expr (val, arg); - return val; - } + return build_target_expr_with_type (arg, DECL_CONTEXT (fn)); } else if (! real_lvalue_p (arg) || TYPE_HAS_TRIVIAL_INIT_REF (DECL_CONTEXT (fn))) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index ac9d37aba41..3c25cad3572 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -3507,7 +3507,7 @@ extern tree cp_namespace_decls PROTO((tree)); extern tree create_implicit_typedef PROTO((tree, tree)); extern tree maybe_push_decl PROTO((tree)); extern void emit_local_var PROTO((tree)); -extern tree build_target_expr PROTO((tree, tree)); +extern tree build_target_expr_with_type PROTO((tree, tree)); extern void make_rtl_for_local_static PROTO((tree)); /* in decl2.c */ diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 79968a86869..19e4d3c253f 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -361,11 +361,7 @@ build_up_reference (type, arg, flags) LOOKUP_ONLYCONVERTING|DIRECT_BIND); } else if (!(flags & DIRECT_BIND) && ! lvalue_p (arg)) - { - tree slot = build_decl (VAR_DECL, NULL_TREE, argtype); - DECL_ARTIFICIAL (slot) = 1; - arg = build_target_expr (slot, arg); - } + return get_target_expr (arg); /* If we had a way to wrap this up, and say, if we ever needed it's address, transform all occurrences of the register, into a memory diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index f01d4de466f..5c231294c2a 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -14091,26 +14091,6 @@ maybe_build_cleanup_1 (decl, auto_delete) return 0; } -/* Build a TARGET_EXPR, initializing the DECL with the VALUE. */ - -tree -build_target_expr (decl, value) - tree decl; - tree value; -{ - tree t; - - t = build (TARGET_EXPR, TREE_TYPE (decl), decl, value, - maybe_build_cleanup (decl), NULL_TREE); - /* We always set TREE_SIDE_EFFECTS so that expand_expr does not - ignore the TARGET_EXPR. If there really turn out to be no - side-effects, then the optimizer should be able to get rid of - whatever code is generated anyhow. */ - TREE_SIDE_EFFECTS (t) = 1; - - return t; -} - /* If DECL is of a type which needs a cleanup, build that cleanup here. The cleanup does free the storage with a call to delete. */ diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index d1b725b2c32..93412738c30 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -43,6 +43,7 @@ static tree no_linkage_helper PROTO((tree *, int *, void *)); static tree build_srcloc PROTO((char *, int)); static void mark_list_hash PROTO ((void *)); static tree copy_tree_r PROTO ((tree *, int *, void *)); +static tree build_target_expr PROTO((tree, tree)); #define CEIL(x,y) (((x) + (y) - 1) / (y)) @@ -213,6 +214,26 @@ lvalue_or_else (ref, string) return win; } +/* Build a TARGET_EXPR, initializing the DECL with the VALUE. */ + +static tree +build_target_expr (decl, value) + tree decl; + tree value; +{ + tree t; + + t = build (TARGET_EXPR, TREE_TYPE (decl), decl, value, + maybe_build_cleanup (decl), NULL_TREE); + /* We always set TREE_SIDE_EFFECTS so that expand_expr does not + ignore the TARGET_EXPR. If there really turn out to be no + side-effects, then the optimizer should be able to get rid of + whatever code is generated anyhow. */ + TREE_SIDE_EFFECTS (t) = 1; + + return t; +} + /* INIT is a CALL_EXPR which needs info about its target. TYPE is the type that this initialization should appear to have. @@ -260,23 +281,35 @@ build_cplus_new (type, init) return rval; } -/* Encapsulate the expression INIT in a TARGET_EXPR. */ +/* Buidl a TARGET_EXPR using INIT to initialize a new temporary of the + indicated TYPE. */ tree -get_target_expr (init) +build_target_expr_with_type (init, type) tree init; + tree type; { tree slot; tree rval; - slot = build (VAR_DECL, TREE_TYPE (init)); + slot = build (VAR_DECL, type); DECL_ARTIFICIAL (slot) = 1; + DECL_CONTEXT (slot) = current_function_decl; layout_decl (slot, 0); rval = build_target_expr (slot, init); return rval; } +/* Like build_target_expr_with_type, but use the type of INIT. */ + +tree +get_target_expr (init) + tree init; +{ + return build_target_expr_with_type (init, TREE_TYPE (init)); +} + /* Recursively search EXP for CALL_EXPRs that need cleanups and replace these CALL_EXPRs with tree nodes that will perform the cleanups. */ -- 2.30.2