aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@yorick.cygnus.com>1998-11-25 00:28:51 +0000
committerJason Merrill <jason@gcc.gnu.org>1998-11-24 19:28:51 -0500
commitc37dc68e57acf01c7ac8c31340ad94c98b2e5214 (patch)
treecf3cbdee8f712a2f2011ea2b09eae4a9ea25960f /gcc
parentc4c2aca36127b4a7c4cfa949227e2e2810a9c004 (diff)
downloadgcc-c37dc68e57acf01c7ac8c31340ad94c98b2e5214.zip
gcc-c37dc68e57acf01c7ac8c31340ad94c98b2e5214.tar.gz
gcc-c37dc68e57acf01c7ac8c31340ad94c98b2e5214.tar.bz2
except.c (expand_throw): Use cp_finish_decl for the throw temp.
* 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. 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. From-SVN: r23845
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog11
-rw-r--r--gcc/cp/call.c3
-rw-r--r--gcc/cp/cvt.c4
-rw-r--r--gcc/cp/except.c13
-rw-r--r--gcc/cp/init.c15
5 files changed, 28 insertions, 18 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 8a8c169..0861bb4 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,16 @@
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.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index ef636e8..f3097e9 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -3412,8 +3412,7 @@ build_over_call (cand, args, flags)
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;
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index ae5fe81..af2f419 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -354,11 +354,13 @@ build_up_reference (type, arg, flags)
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;
}
diff --git a/gcc/cp/except.c b/gcc/cp/except.c
index a1d028e..7da22cd 100644
--- a/gcc/cp/except.c
+++ b/gcc/cp/except.c
@@ -687,7 +687,8 @@ process_start_catch_block (declspecs, declarator)
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
{
@@ -1027,13 +1028,11 @@ expand_throw (exp)
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
@@ -1072,7 +1071,7 @@ expand_throw (exp)
/* 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)
{
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 6017298..07a405f 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -1138,14 +1138,13 @@ expand_default_init (binfo, true_exp, exp, init, flags)
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)