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
This commit is contained in:
parent
794d4a61f8
commit
c506ca222b
|
@ -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.
|
||||
|
|
|
@ -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)))
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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. */
|
||||
|
||||
|
|
|
@ -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,21 +281,33 @@ 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
|
||||
build_target_expr_with_type (init, type)
|
||||
tree init;
|
||||
tree type;
|
||||
{
|
||||
tree slot;
|
||||
tree rval;
|
||||
|
||||
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;
|
||||
{
|
||||
tree slot;
|
||||
tree rval;
|
||||
|
||||
slot = build (VAR_DECL, TREE_TYPE (init));
|
||||
DECL_ARTIFICIAL (slot) = 1;
|
||||
layout_decl (slot, 0);
|
||||
rval = build_target_expr (slot, init);
|
||||
|
||||
return rval;
|
||||
return build_target_expr_with_type (init, TREE_TYPE (init));
|
||||
}
|
||||
|
||||
/* Recursively search EXP for CALL_EXPRs that need cleanups and replace
|
||||
|
|
Loading…
Reference in New Issue