OSDN Git Service

* cp-tree.h (AGGR_INIT_VIA_CTOR_P): New macro.
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 27 Aug 1999 04:58:19 +0000 (04:58 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 27 Aug 1999 04:58:19 +0000 (04:58 +0000)
* tree.c (build_cplus_new): Set it.
* expr.c (cplus_expand_expr): Use it.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@28915 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/expr.c
gcc/cp/tree.c

index 0d1bec3..521710c 100644 (file)
@@ -1,5 +1,9 @@
 1999-08-26  Mark Mitchell  <mark@codesourcery.com>
 
+       * cp-tree.def (AGGR_INIT_VIA_CTOR_P): New macro.
+       * tree.c (build_cplus_new): Set it.
+       * expr.c (cplus_expand_expr): Use it.
+
        * decl.c (store_parm_decls): Reset immediate_size_expand.
        (finish_function): Likewise.
        
index f544ca3..a9f4b29 100644 (file)
@@ -36,6 +36,7 @@ Boston, MA 02111-1307, USA.  */
       LOCAL_BINDING_P (in CPLUS_BINDING)
       ICS_USER_FLAG (in _CONV)
       CLEANUP_P (in TRY_BLOCK)
+      AGGR_INIT_VIA_CTOR_P (in AGGR_INIT_EXPR)
    1: IDENTIFIER_VIRTUAL_P.
       TI_PENDING_TEMPLATE_FLAG.
       TEMPLATE_PARMS_FOR_INLINE.
@@ -1528,6 +1529,10 @@ struct lang_decl
 #define DELETE_EXPR_USE_VEC(NODE)      TREE_LANG_FLAG_1 (NODE)
 #define LOOKUP_EXPR_GLOBAL(NODE)       TREE_LANG_FLAG_0 (NODE)
 
+/* Nonzero if this AGGR_INIT_EXPR provides for initialization via a
+   constructor call, rather than an ordinary function call.  */
+#define AGGR_INIT_VIA_CTOR_P(NODE) TREE_LANG_FLAG_0 (NODE)
+
 /* The TYPE_MAIN_DECL for a class template type is a TYPE_DECL, not a
    TEMPLATE_DECL.  This macro determines whether or not a given class
    type is really a template type, as opposed to an instantiation or
index e85e088..373afe6 100644 (file)
@@ -154,9 +154,7 @@ cplus_expand_expr (exp, target, tmode, modifier)
           initialization.  It is left here to show the choices that
           exist for C++.  */
           
-       if (TREE_CODE (func) == ADDR_EXPR
-           && TREE_CODE (TREE_OPERAND (func, 0)) == FUNCTION_DECL
-           && DECL_CONSTRUCTOR_P (TREE_OPERAND (func, 0)))
+       if (AGGR_INIT_VIA_CTOR_P (exp))
          {
            type = build_pointer_type (type);
            /* Don't clobber a value that might be part of a default
index 0b62533..68357c0 100644 (file)
@@ -220,6 +220,7 @@ build_cplus_new (type, init)
      tree type;
      tree init;
 {
+  tree fn;
   tree slot;
   tree rval;
 
@@ -233,9 +234,22 @@ build_cplus_new (type, init)
   slot = build (VAR_DECL, type);
   DECL_ARTIFICIAL (slot) = 1;
   layout_decl (slot, 0);
-  rval = build (AGGR_INIT_EXPR, type,
-               TREE_OPERAND (init, 0), TREE_OPERAND (init, 1), slot);
+
+  /* We split the CALL_EXPR into its function and its arguments here.
+     Then, in expand_expr, we put them back together.  The reason for
+     this is that this expression might be a default argument
+     expression.  In that case, we need a new temporary every time the
+     expression is used.  That's what break_out_target_exprs does; it
+     replaces every AGGR_INIT_EXPR with a copy that uses a fresh
+     temporary slot.  Then, expand_expr builds up a call-expression
+     using the new slot.  */
+  fn = TREE_OPERAND (init, 0);
+  rval = build (AGGR_INIT_EXPR, type, fn, TREE_OPERAND (init, 1), slot);
   TREE_SIDE_EFFECTS (rval) = 1;
+  AGGR_INIT_VIA_CTOR_P (rval) 
+    = (TREE_CODE (fn) == ADDR_EXPR
+       && TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL
+       && DECL_CONSTRUCTOR_P (TREE_OPERAND (fn, 0)));
   rval = build (TARGET_EXPR, type, slot, rval, NULL_TREE, NULL_TREE);
   TREE_SIDE_EFFECTS (rval) = 1;