OSDN Git Service

* function.c (free_temps_for_rtl_expr): Don't free slots
[pf3gnuchains/gcc-fork.git] / gcc / cp / expr.c
index 741174e..3fe6f99 100644 (file)
@@ -1,6 +1,7 @@
 /* Convert language-specific tree expression to rtl instructions,
    for GNU compiler.
-   Copyright (C) 1988, 92-97, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+   2000 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -28,12 +29,14 @@ Boston, MA 02111-1307, USA.  */
 #include "expr.h"
 #include "cp-tree.h"
 #include "toplev.h"
+#include "except.h"
+#include "tm_p.h"
 
 #if 0
-static tree extract_aggr_init PROTO((tree, tree));
-static tree extract_scalar_init PROTO((tree, tree));
+static tree extract_aggr_init PARAMS ((tree, tree));
+static tree extract_scalar_init PARAMS ((tree, tree));
 #endif
-static rtx cplus_expand_expr PROTO((tree, rtx, enum machine_mode,
+static rtx cplus_expand_expr PARAMS ((tree, rtx, enum machine_mode,
                                    enum expand_modifier));
 
 /* Hook used by output_constant to expand language-specific
@@ -60,13 +63,12 @@ cplus_expand_constant (cst)
            offset = convert (sizetype,
                              size_binop (EASY_DIV_EXPR,
                                          DECL_FIELD_BITPOS (member),
-                                         size_int (BITS_PER_UNIT)));
+                                         bitsize_int (BITS_PER_UNIT)));
 
            /* We offset all pointer to data members by 1 so that we
               can distinguish between a null pointer to data member
               and the first data member of a structure.  */
-           offset = size_binop (PLUS_EXPR, offset, size_int (1));
-       
+           offset = size_binop (PLUS_EXPR, offset, size_one_node);
            cst = cp_convert (type, offset);
          }
        else
@@ -118,102 +120,6 @@ cplus_expand_expr (exp, target, tmode, modifier)
 
   switch (code)
     {
-    case AGGR_INIT_EXPR:
-      {
-       /* Something needs to be initialized, but we didn't know
-          where that thing was when building the tree.  For example,
-          it could be the return value of a function, or a parameter
-          to a function which lays down in the stack, or a temporary
-          variable which must be passed by reference.
-
-          Cleanups are handled in a language-specific way: they
-          might be run by the called function (true in GNU C++
-          for parameters with cleanups), or they might be
-          run by the caller, after the call (true in GNU C++
-          for other cleanup needs).  */
-
-       tree func = TREE_OPERAND (exp, 0);
-       tree args = TREE_OPERAND (exp, 1);
-       tree type = TREE_TYPE (exp), slot;
-       tree call_exp;
-       rtx call_target, return_target;
-       int pcc_struct_return = 0;
-
-       /* The expression `init' wants to initialize what
-          `target' represents.  SLOT holds the slot for TARGET.  */
-       slot = TREE_OPERAND (exp, 2);
-
-       /* Should always be called with a target.  */
-       my_friendly_assert (target != NULL_RTX, 205);
-
-       /* The target the initializer will initialize (CALL_TARGET)
-          must now be directed to initialize the target we are
-          supposed to initialize (TARGET).  The semantics for
-          choosing what CALL_TARGET is is language-specific,
-          as is building the call which will perform the
-          initialization.  It is left here to show the choices that
-          exist for C++.  */
-          
-       if (AGGR_INIT_VIA_CTOR_P (exp))
-         {
-           type = build_pointer_type (type);
-           mark_addressable (slot);
-           args = tree_cons (NULL_TREE, 
-                             build1 (ADDR_EXPR, type, slot),
-                             TREE_CHAIN (args));
-           call_target = 0;
-         }
-       else
-         {
-           call_target = target;
-#ifdef PCC_STATIC_STRUCT_RETURN
-           if (aggregate_value_p (type))
-             {
-               pcc_struct_return = 1;
-               call_target = 0;
-             }
-#endif
-         }
-
-       call_exp = build (CALL_EXPR, type, func, args, NULL_TREE);
-       TREE_SIDE_EFFECTS (call_exp) = 1;
-       return_target = expand_call (call_exp, call_target, ignore);
-
-       if (call_target)
-         /* Trust that the right thing has been done; it's too hard to
-            verify.  */
-         return return_target;
-
-       /* If we're suffering under the ancient PCC_STATIC_STRUCT_RETURN
-          calling convention, we need to copy the return value out of
-          the static return buffer into slot.  */
-       if (pcc_struct_return)
-         {
-           extern int flag_access_control;
-           int old_ac = flag_access_control;
-
-           tree init = build_decl (VAR_DECL, NULL_TREE,
-                                   build_reference_type (type));
-           DECL_RTL (init) = XEXP (return_target, 0);
-           init = convert_from_reference (init);
-
-           flag_access_control = 0;
-           expand_expr (build_aggr_init (slot, init,
-                                         LOOKUP_ONLYCONVERTING), 
-                        target, tmode, EXPAND_NORMAL);
-           flag_access_control = old_ac;
-
-           if (TYPE_NEEDS_DESTRUCTOR (type))
-             {
-               init = maybe_build_cleanup (init);
-               if (init != NULL_TREE)
-                 expand_expr (init, const0_rtx, VOIDmode, 0);
-             }
-         }
-
-       return DECL_RTL (slot);
-      }
-
     case PTRMEM_CST:
       return expand_expr (cplus_expand_constant (exp),
                          target, tmode, modifier);
@@ -225,25 +131,23 @@ cplus_expand_expr (exp, target, tmode, modifier)
       }
 
     case THUNK_DECL:
+      my_friendly_assert (DECL_RTL (exp) != NULL_RTX, 20000115);
       return DECL_RTL (exp);
 
     case THROW_EXPR:
-      expand_throw (TREE_OPERAND (exp, 0));
+      expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
+      expand_internal_throw ();
       return NULL;
 
-    case VEC_INIT_EXPR:
-      return expand_expr
-       (build_vec_init
-        (NULL_TREE, TREE_OPERAND (exp, 0),
-         build_binary_op (MINUS_EXPR, TREE_OPERAND (exp, 2),
-                          integer_one_node),
-         TREE_OPERAND (exp, 1), 0), target, tmode, modifier);
+    case EMPTY_CLASS_EXPR:
+      /* We don't need to generate any code for an empty class.  */
+      return const0_rtx;
 
     case STMT_EXPR:
       {
-       tree rtl_expr = begin_stmt_expr ();
+       tree rtl_expr = expand_start_stmt_expr ();
        expand_stmt (STMT_EXPR_STMT (exp));
-       finish_stmt_expr (rtl_expr);
+       expand_end_stmt_expr (rtl_expr);
        return expand_expr (rtl_expr, target, tmode, modifier);
       }
       break;
@@ -312,14 +216,12 @@ extract_scalar_init (decl, init)
   extern struct obstack temporary_obstack;
   tree t = NULL_TREE;
 
-  push_obstacks (&temporary_obstack, &temporary_obstack);
   start_sequence ();
   value = expand_expr (init, NULL_RTX, VOIDmode, 0);
   insns = get_insns ();
   end_sequence ();
   reg_scan (insns, max_reg_num (), 0);
   jump_optimize (insns, 0, 0, 1);
-  pop_obstacks ();
 
   for (insn = insns; insn; insn = NEXT_INSN (insn))
     {
@@ -388,7 +290,7 @@ do_case (start, end)
     error ("pointers are not permitted as case values");
 
   if (end && pedantic)
-    pedwarn ("ANSI C++ forbids range expressions in switch statement");
+    pedwarn ("ISO C++ forbids range expressions in switch statement");
 
   if (start)
     value1 = check_cp_case_value (start);