OSDN Git Service

Merge in gcc2-ss-010999
[pf3gnuchains/gcc-fork.git] / gcc / cp / tree.c
index 61ad108..a1928ef 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;
 
@@ -508,7 +522,10 @@ cp_build_qualified_type_real (type, type_quals, complain)
 
   if (type == error_mark_node)
     return type;
-  
+
+  if (type_quals == TYPE_QUALS (type))
+    return type;
+
   /* A restrict-qualified pointer type must be a pointer (or reference)
      to object or incomplete type.  */
   if ((type_quals & TYPE_QUAL_RESTRICT)
@@ -888,7 +905,7 @@ build_base_fields (rec)
       if (TREE_VIA_VIRTUAL (base_binfo))
        continue;
 
-      decl = build_lang_field_decl (FIELD_DECL, NULL_TREE, basetype);
+      decl = build_lang_decl (FIELD_DECL, NULL_TREE, basetype);
       DECL_ARTIFICIAL (decl) = 1;
       DECL_FIELD_CONTEXT (decl) = DECL_CLASS_CONTEXT (decl) = rec;
       DECL_SIZE (decl) = CLASSTYPE_SIZE (basetype);
@@ -1000,8 +1017,8 @@ build_vbase_pointer_fields (rec)
                goto got_it;
            }
          FORMAT_VBASE_NAME (name, basetype);
-         decl = build_lang_field_decl (FIELD_DECL, get_identifier (name),
-                                       build_pointer_type (basetype));
+         decl = build_lang_decl (FIELD_DECL, get_identifier (name),
+                                 build_pointer_type (basetype));
          /* If you change any of the below, take a look at all the
             other VFIELD_BASEs and VTABLE_BASEs in the code, and change
             them too.  */
@@ -1443,7 +1460,7 @@ is_aggr_type_2 (t1, t2)
 \f
 #define PRINT_RING_SIZE 4
 
-char *
+const char *
 lang_printable_name (decl, v)
      tree decl;
      int v;
@@ -1640,6 +1657,9 @@ search_tree (t, func)
       TRY (TREE_OPERAND (t, 2));
       break;
 
+    case TRUTH_AND_EXPR:
+    case TRUTH_OR_EXPR:
+    case TRUTH_XOR_EXPR:
     case TRUTH_ANDIF_EXPR:
     case TRUTH_ORIF_EXPR:
     case PREDECREMENT_EXPR:
@@ -1653,6 +1673,7 @@ search_tree (t, func)
     case CALL_EXPR:
     case COMPOUND_EXPR:
     case MODIFY_EXPR:
+    case INIT_EXPR:
       TRY (TREE_OPERAND (t, 0));
       TRY (TREE_OPERAND (t, 1));
       break;
@@ -1665,6 +1686,8 @@ search_tree (t, func)
     case CLEANUP_POINT_EXPR:
     case LOOKUP_EXPR:
     case THROW_EXPR:
+    case EXIT_EXPR:
+    case LOOP_EXPR:
       TRY (TREE_OPERAND (t, 0));
       break;
 
@@ -1672,6 +1695,7 @@ search_tree (t, func)
     case ARROW_EXPR:
     case DOTSTAR_EXPR:
     case TYPEID_EXPR:
+    case PSEUDO_DTOR_EXPR:
       break;
 
     case COMPLEX_CST:
@@ -1899,6 +1923,9 @@ mapcar (t, func)
       TREE_OPERAND (t, 2) = mapcar (TREE_OPERAND (t, 2), func);
       return t;
 
+    case TRUTH_AND_EXPR:
+    case TRUTH_OR_EXPR:
+    case TRUTH_XOR_EXPR:
     case TRUTH_ANDIF_EXPR:
     case TRUTH_ORIF_EXPR:
     case PREDECREMENT_EXPR:
@@ -1911,6 +1938,7 @@ mapcar (t, func)
     case WITH_CLEANUP_EXPR:
     case COMPOUND_EXPR:
     case MODIFY_EXPR:
+    case INIT_EXPR:
       t = copy_node (t);
       TREE_OPERAND (t, 0) = mapcar (TREE_OPERAND (t, 0), func);
       TREE_OPERAND (t, 1) = mapcar (TREE_OPERAND (t, 1), func);
@@ -1994,6 +2022,8 @@ mapcar (t, func)
       return t;
 
     case LOOKUP_EXPR:
+    case EXIT_EXPR:
+    case LOOP_EXPR:
       t = copy_node (t);
       TREE_OPERAND (t, 0) = mapcar (TREE_OPERAND (t, 0), func);
       return t;
@@ -2177,7 +2207,7 @@ break_out_target_exprs (t)
 tree
 build_min_nt VPROTO((enum tree_code code, ...))
 {
-#ifndef __STDC__
+#ifndef ANSI_PROTOTYPES
   enum tree_code code;
 #endif
   register struct obstack *ambient_obstack = expression_obstack;
@@ -2188,7 +2218,7 @@ build_min_nt VPROTO((enum tree_code code, ...))
 
   VA_START (p, code);
 
-#ifndef __STDC__
+#ifndef ANSI_PROTOTYPES
   code = va_arg (p, enum tree_code);
 #endif
 
@@ -2215,7 +2245,7 @@ build_min_nt VPROTO((enum tree_code code, ...))
 tree
 build_min VPROTO((enum tree_code code, tree tt, ...))
 {
-#ifndef __STDC__
+#ifndef ANSI_PROTOTYPES
   enum tree_code code;
   tree tt;
 #endif
@@ -2227,7 +2257,7 @@ build_min VPROTO((enum tree_code code, tree tt, ...))
 
   VA_START (p, tt);
 
-#ifndef __STDC__
+#ifndef ANSI_PROTOTYPES
   code = va_arg (p, enum tree_code);
   tt = va_arg (p, tree);
 #endif
@@ -2850,12 +2880,12 @@ init_cplus_unsave ()
 /* The C++ version of unsave_expr_now.
    See gcc/tree.c:unsave_expr_now for comments. */
 
-tree
+void
 cplus_unsave_expr_now (expr)
      tree expr;
 {
   if (expr == NULL)
-    return expr;
+    return;
 
   else if (TREE_CODE (expr) == AGGR_INIT_EXPR)
     {
@@ -2871,10 +2901,10 @@ cplus_unsave_expr_now (expr)
            }
        }
       unsave_expr_now (TREE_OPERAND (expr,2));
-      return expr;
+      return;
     }
 
   else
-    return expr;
+    return;
 }