* except.c (expand_throw): Use cp_finish_decl for the throw temp.
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 25 Nov 1998 00:28:51 +0000 (00:28 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 25 Nov 1998 00:28:51 +0000 (00:28 +0000)
* 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

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/cvt.c
gcc/cp/except.c
gcc/cp/init.c

index 8a8c169..0861bb4 100644 (file)
@@ -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.
index ef636e8..f3097e9 100644 (file)
@@ -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;
index ae5fe81..af2f419 100644 (file)
@@ -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;
     }
index a1d028e..7da22cd 100644 (file)
@@ -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)
        {
index 6017298..07a405f 100644 (file)
@@ -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)