diff options
author | Mark Mitchell <mark@codesourcery.com> | 1999-11-14 05:04:19 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 1999-11-14 05:04:19 +0000 |
commit | c506ca222b67f823e968193b4b1c7f4f5d814062 (patch) | |
tree | 31adff7c914e81c695f58a7804b07e16ea46c1e0 | |
parent | 794d4a61f8208daf82205681b6081fa560b68ddd (diff) | |
download | gcc-c506ca222b67f823e968193b4b1c7f4f5d814062.zip gcc-c506ca222b67f823e968193b4b1c7f4f5d814062.tar.gz gcc-c506ca222b67f823e968193b4b1c7f4f5d814062.tar.bz2 |
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
-rw-r--r-- | gcc/cp/ChangeLog | 14 | ||||
-rw-r--r-- | gcc/cp/call.c | 17 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 2 | ||||
-rw-r--r-- | gcc/cp/cvt.c | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 20 | ||||
-rw-r--r-- | gcc/cp/tree.c | 39 |
6 files changed, 55 insertions, 43 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8bd88f3..da62559 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,17 @@ +1999-11-13 Mark Mitchell <mark@codesourcery.com> + + * 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 <jason@yorick.cygnus.com> * decl.c (duplicate_decls): Propagate DECL_DEFER_OUTPUT. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 38ce371..ee12743 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 ac9d37a..3c25cad 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 79968a8..19e4d3c 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 f01d4de..5c23129 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 d1b725b..9341273 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. */ |