* 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
+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.
?: 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. */
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
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)))
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 */
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
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. */
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))
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.
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. */