* cvt.c (build_up_reference): Pass DIRECT_BIND down into
cp_finish_decl.
* init.c (expand_default_init): Check for DIRECT_BIND instead of
DECL_ARTIFICIAL.
Fixes Sec15/1/P15140.C, g++.eh/ctor1.C.
* call.c (build_over_call): Use build_decl.
* except.c (expand_throw): Just use convert, not
build_reinterpret_cast.
Fixes Sec15/P15113.C.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@23845
138bc75d-0d04-0410-961f-
82ee72b054a4
1998-11-24 Jason Merrill <jason@yorick.cygnus.com>
+ * except.c (expand_throw): Use cp_finish_decl for the throw temp.
+ * cvt.c (build_up_reference): Pass DIRECT_BIND down into
+ cp_finish_decl.
+ * init.c (expand_default_init): Check for DIRECT_BIND instead of
+ DECL_ARTIFICIAL.
+
+ * call.c (build_over_call): Use build_decl.
+
+ * except.c (expand_throw): Just use convert, not
+ build_reinterpret_cast.
+
* lex.c (handle_generic_pragma): Use token_buffer.
* decl.c (check_tag_decl): Don't complain about null friend decl.
return arg;
else if (TYPE_HAS_TRIVIAL_INIT_REF (DECL_CONTEXT (fn)))
{
- val = build (VAR_DECL, DECL_CONTEXT (fn));
- layout_decl (val, 0);
+ val = build_decl (VAR_DECL, NULL_TREE, DECL_CONTEXT (fn));
val = build (TARGET_EXPR, DECL_CONTEXT (fn), val, arg, 0, 0);
TREE_SIDE_EFFECTS (val) = 1;
return val;
DECL_ARTIFICIAL (arg) = 1;
}
DECL_INITIAL (arg) = targ;
- cp_finish_decl (arg, targ, NULL_TREE, 0, LOOKUP_ONLYCONVERTING);
+ cp_finish_decl (arg, targ, NULL_TREE, 0,
+ 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, argtype, slot, arg, NULL_TREE, NULL_TREE);
TREE_SIDE_EFFECTS (arg) = 1;
}
decl = pushdecl (decl);
start_decl_1 (decl);
- cp_finish_decl (decl, init, NULL_TREE, 0, LOOKUP_ONLYCONVERTING);
+ cp_finish_decl (decl, init, NULL_TREE, 0,
+ LOOKUP_ONLYCONVERTING|DIRECT_BIND);
}
else
{
ourselves into expand_call. */
if (TREE_SIDE_EFFECTS (exp))
{
- tree temp = build (VAR_DECL, TREE_TYPE (exp));
+ tree temp = build_decl (VAR_DECL, NULL_TREE, TREE_TYPE (exp));
DECL_ARTIFICIAL (temp) = 1;
- layout_decl (temp, 0);
DECL_RTL (temp) = assign_temp (TREE_TYPE (exp), 2, 0, 1);
- expand_expr (build (INIT_EXPR, TREE_TYPE (exp), temp, exp),
- NULL_RTX, VOIDmode, 0);
- expand_decl_cleanup (NULL_TREE, maybe_build_cleanup (temp));
+ DECL_INITIAL (temp) = exp;
+ cp_finish_decl (temp, exp, NULL_TREE, 0, LOOKUP_ONLYCONVERTING);
exp = temp;
}
#endif
/* Cast EXP to `void *' so that it will match the prototype for
__cp_push_exception. */
- exp = build_reinterpret_cast (ptr_type_node, exp);
+ exp = convert (ptr_type_node, exp);
if (cleanup == NULL_TREE)
{
if (true_exp != exp)
abort ();
- /* We special-case TARGET_EXPRs here to avoid an error about
- private copy constructors for temporaries bound to reference vars.
- If the TARGET_EXPR represents a call to a function that has
- permission to create such objects, a reference can bind directly
- to the return value. An object variable must be initialized
- via the copy constructor, even if the call is elided. */
- if (! (TREE_CODE (exp) == VAR_DECL && DECL_ARTIFICIAL (exp)
- && TREE_CODE (init) == TARGET_EXPR && TREE_TYPE (init) == type))
+ if (flags & DIRECT_BIND)
+ /* Do nothing. We hit this in two cases: Reference initialization,
+ where we aren't initializing a real variable, so we don't want
+ to run a new constructor; and catching an exception, where we
+ have already built up the constructor call so we could wrap it
+ in an exception region. */;
+ else
init = ocp_convert (type, init, CONV_IMPLICIT|CONV_FORCE_TEMP, flags);
if (TREE_CODE (init) == TRY_CATCH_EXPR)