OSDN Git Service

* init.c (build_new): Allow enumeration types for the array-bounds
[pf3gnuchains/gcc-fork.git] / gcc / stmt.c
index f2763e7..8465df7 100644 (file)
@@ -106,8 +106,12 @@ typedef struct case_node *case_node_ptr;
 
 /* This must be a signed type, and non-ANSI compilers lack signed char.  */
 static short cost_table_[129];
-static short *cost_table;
 static int use_cost_table;
+static int cost_table_initialized;
+
+/* Special care is needed because we allow -1, but TREE_INT_CST_LOW
+   is unsigned.  */
+#define COST_TABLE(I)  cost_table_[(unsigned HOST_WIDE_INT)((I) + 1)]
 \f
 /* Stack of control and binding constructs we are currently inside.
 
@@ -240,8 +244,6 @@ struct nesting
          tree index_expr;
          /* Type that INDEX_EXPR should be converted to.  */
          tree nominal_type;
-         /* Number of range exprs in case statement.  */
-         int num_ranges;
          /* Name of this kind of statement, for warnings.  */
          const char *printname;
          /* Used to save no_line_numbers till we see the first case label.
@@ -395,9 +397,6 @@ struct stmt_status
 /* Non-zero if we are using EH to handle cleanus.  */
 static int using_eh_for_cleanups_p = 0;
 
-/* Character strings, each containing a single decimal digit.  */
-static char *digit_strings[10];
-
 static int n_occurrences               PARAMS ((int, const char *));
 static void expand_goto_internal       PARAMS ((tree, rtx, rtx));
 static int expand_fixup                        PARAMS ((tree, rtx, rtx));
@@ -421,7 +420,6 @@ static int node_has_high_bound              PARAMS ((case_node_ptr, tree));
 static int node_is_bounded             PARAMS ((case_node_ptr, tree));
 static void emit_jump_if_reachable     PARAMS ((rtx));
 static void emit_case_nodes            PARAMS ((rtx, case_node_ptr, rtx, tree));
-static int add_case_node               PARAMS ((tree, tree, tree, tree *));
 static struct case_node *case_tree2list        PARAMS ((case_node *, case_node *));
 static void mark_cond_nesting           PARAMS ((struct nesting *));
 static void mark_loop_nesting           PARAMS ((struct nesting *));
@@ -429,7 +427,7 @@ static void mark_block_nesting          PARAMS ((struct nesting *));
 static void mark_case_nesting           PARAMS ((struct nesting *));
 static void mark_case_node             PARAMS ((struct case_node *));
 static void mark_goto_fixup             PARAMS ((struct goto_fixup *));
-
+static void free_case_nodes             PARAMS ((case_node_ptr));
 \f
 void
 using_eh_for_cleanups ()
@@ -488,8 +486,11 @@ mark_block_nesting (n)
       ggc_mark_tree (n->data.block.cleanups);
       ggc_mark_tree (n->data.block.outer_cleanups);
 
-      for (l = n->data.block.label_chain; l != NULL; l = l->next)
-       ggc_mark_tree (l->label);
+      for (l = n->data.block.label_chain; l != NULL; l = l->next) 
+       {
+         ggc_mark (l);
+         ggc_mark_tree (l->label);
+       }
 
       ggc_mark_rtx (n->data.block.last_unconditional_cleanup);
 
@@ -597,16 +598,7 @@ mark_stmt_status (p)
 void
 init_stmt ()
 {
-  int i;
-
   gcc_obstack_init (&stmt_obstack);
-
-  for (i = 0; i < 10; i++)
-    {
-      digit_strings[i] = ggc_alloc_string (NULL, 1);
-      digit_strings[i][0] = '0' + i;
-    }
-  ggc_add_string_root (digit_strings, 10);
 }
 
 void
@@ -716,7 +708,7 @@ expand_computed_goto (exp)
   emit_queue ();
   /* Be sure the function is executable.  */
   if (current_function_check_memory_usage)
-    emit_library_call (chkr_check_exec_libfunc, 1,
+    emit_library_call (chkr_check_exec_libfunc, LCT_CONST_MAKE_BLOCK,
                       VOIDmode, 1, x, ptr_mode);
 
   do_pending_stack_adjust ();
@@ -751,7 +743,7 @@ expand_label (label)
 
   if (stack_block_stack != 0)
     {
-      p = (struct label_chain *) oballoc (sizeof (struct label_chain));
+      p = (struct label_chain *) ggc_alloc (sizeof (struct label_chain));
       p->next = stack_block_stack->data.block.label_chain;
       stack_block_stack->data.block.label_chain = p;
       p->label = label;
@@ -795,7 +787,7 @@ expand_goto (label)
     {
       struct function *p = find_function_data (context);
       rtx label_ref = gen_rtx_LABEL_REF (Pmode, label_rtx (label));
-      rtx handler_slot, static_chain, save_area;
+      rtx handler_slot, static_chain, save_area, insn;
       tree link;
 
       /* Find the corresponding handler slot for this label.  */
@@ -848,6 +840,15 @@ expand_goto (label)
          emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
          emit_indirect_jump (handler_slot);
        }
+
+      /* Search backwards to the jump insn and mark it as a 
+        non-local goto.  */
+      for (insn = get_last_insn ();
+          GET_CODE (insn) != JUMP_INSN; 
+          insn = PREV_INSN (insn))
+       continue;
+      REG_NOTES (insn) = alloc_EXPR_LIST (REG_NON_LOCAL_GOTO, const0_rtx,
+                                         REG_NOTES (insn));
     }
   else
     expand_goto_internal (label, label_rtx (label), NULL_RTX);
@@ -1408,7 +1409,7 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
     {
       tree val = TREE_VALUE (tail);
       tree type = TREE_TYPE (val);
-      char *constraint;
+      const char *constraint;
       char *p;
       int c_len;
       int j;
@@ -1425,8 +1426,8 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
         the worst that happens if we get it wrong is we issue an error
         message.  */
 
-      c_len = strlen (TREE_STRING_POINTER (TREE_PURPOSE (tail)));
       constraint = TREE_STRING_POINTER (TREE_PURPOSE (tail));
+      c_len = strlen (constraint);
 
       /* Allow the `=' or `+' to not be at the beginning of the string,
         since it wasn't explicitly documented that way, and there is a
@@ -1443,19 +1444,25 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
          error ("output operand constraint lacks `='");
          return;
        }
+      j = p - constraint;
+      is_inout = *p == '+';
 
-      if (p != constraint)
+      if (j || is_inout)
        {
-         j = *p;
-         bcopy (constraint, constraint+1, p-constraint);
-         *constraint = j;
-
-         warning ("output constraint `%c' for operand %d is not at the beginning", j, i);
+         /* Have to throw away this constraint string and get a new one.  */
+         char *buf = alloca (c_len + 1);
+         buf[0] = '=';
+         if (j)
+           memcpy (buf + 1, constraint, j);
+         memcpy (buf + 1 + j, p + 1, c_len - j);  /* not -j-1 - copy null */
+         constraint = ggc_alloc_string (buf, c_len);
+
+         if (j)
+           warning (
+               "output constraint `%c' for operand %d is not at the beginning",
+               *p, i);
        }
 
-      is_inout = constraint[0] == '+';
-      /* Replace '+' with '='.  */
-      constraint[0] = '=';
       /* Make sure we can specify the matching operand.  */
       if (is_inout && i > 9)
        {
@@ -1479,7 +1486,7 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
              }
            break;
 
-         case '?':  case '!':  case '*':  case '&':
+         case '?':  case '!':  case '*':  case '&':  case '#':
          case 'E':  case 'F':  case 'G':  case 'H':
          case 's':  case 'i':  case 'n':
          case 'I':  case 'J':  case 'K':  case 'L':  case 'M':
@@ -1595,7 +1602,9 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
   argvec = rtvec_alloc (ninputs);
   constraints = rtvec_alloc (ninputs);
 
-  body = gen_rtx_ASM_OPERANDS (VOIDmode, TREE_STRING_POINTER (string),
+  body = gen_rtx_ASM_OPERANDS ((noutputs == 0 ? VOIDmode
+                               : GET_MODE (output_rtx[0])),
+                              TREE_STRING_POINTER (string), 
                               empty_string, 0, argvec, constraints,
                               filename, line);
 
@@ -1609,7 +1618,7 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
     {
       int j;
       int allows_reg = 0, allows_mem = 0;
-      char *constraint, *orig_constraint;
+      const char *constraint, *orig_constraint;
       int c_len;
       rtx op;
 
@@ -1627,8 +1636,8 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
          return;
        }
 
-      c_len = strlen (TREE_STRING_POINTER (TREE_PURPOSE (tail)));
       constraint = TREE_STRING_POINTER (TREE_PURPOSE (tail));
+      c_len = strlen (constraint);
       orig_constraint = constraint;
 
       /* Make sure constraint has neither `=', `+', nor '&'.  */
@@ -1659,7 +1668,7 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
            break;
 
          case '<':  case '>':
-         case '?':  case '!':  case '*':
+         case '?':  case '!':  case '*':  case '#':
          case 'E':  case 'F':  case 'G':  case 'H':
          case 's':  case 'i':  case 'n':
          case 'I':  case 'J':  case 'K':  case 'L':  case 'M':
@@ -1689,8 +1698,8 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
                for (j = constraint[j] - '0'; j > 0; --j)
                  o = TREE_CHAIN (o);
 
-               c_len = strlen (TREE_STRING_POINTER (TREE_PURPOSE (o)));
                constraint = TREE_STRING_POINTER (TREE_PURPOSE (o));
+               c_len = strlen (constraint);
                j = 0;
                break;
              }
@@ -1752,7 +1761,10 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
                   || GET_CODE (op) == CONCAT)
            {
              tree type = TREE_TYPE (TREE_VALUE (tail));
-             rtx memloc = assign_temp (type, 1, 1, 1);
+             tree qual_type = build_qualified_type (type,
+                                                    (TYPE_QUALS (type)
+                                                     | TYPE_QUAL_CONST));
+             rtx memloc = assign_temp (qual_type, 1, 1, 1);
 
              emit_move_insn (memloc, op);
              op = memloc;
@@ -1771,9 +1783,9 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
            warning ("asm operand %d probably doesn't match constraints", i);
        }
       generating_concat_p = old_generating_concat_p;
-      XVECEXP (body, 3, i) = op;
+      ASM_OPERANDS_INPUT (body, i) = op;
 
-      XVECEXP (body, 4, i)      /* constraints */
+      ASM_OPERANDS_INPUT_CONSTRAINT_EXP (body, i)
        = gen_rtx_ASM_INPUT (TYPE_MODE (TREE_TYPE (TREE_VALUE (tail))),
                             orig_constraint);
       i++;
@@ -1785,7 +1797,8 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
   generating_concat_p = 0;
 
   for (i = 0; i < ninputs - ninout; i++)
-    XVECEXP (body, 3, i) = protect_from_queue (XVECEXP (body, 3, i), 0);
+    ASM_OPERANDS_INPUT (body, i)
+      = protect_from_queue (ASM_OPERANDS_INPUT (body, i), 0);
 
   for (i = 0; i < noutputs; i++)
     output_rtx[i] = protect_from_queue (output_rtx[i], 1);
@@ -1795,10 +1808,10 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
     {
       int j = inout_opnum[i];
 
-      XVECEXP (body, 3, ninputs - ninout + i)      /* argvec */
+      ASM_OPERANDS_INPUT (body, ninputs - ninout + i)
        = output_rtx[j];
-      XVECEXP (body, 4, ninputs - ninout + i)      /* constraints */
-       = gen_rtx_ASM_INPUT (inout_mode[i], digit_strings[j]);
+      ASM_OPERANDS_INPUT_CONSTRAINT_EXP (body, ninputs - ninout + i)
+       = gen_rtx_ASM_INPUT (inout_mode[i], digit_string (j));
     }
 
   generating_concat_p = old_generating_concat_p;
@@ -1810,7 +1823,8 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
 
   if (noutputs == 1 && nclobbers == 0)
     {
-      XSTR (body, 1) = TREE_STRING_POINTER (TREE_PURPOSE (outputs));
+      ASM_OPERANDS_OUTPUT_CONSTRAINT (body)
+       = TREE_STRING_POINTER (TREE_PURPOSE (outputs));
       insn = emit_insn (gen_rtx_SET (VOIDmode, output_rtx[0], body));
     }
 
@@ -1837,7 +1851,7 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
            = gen_rtx_SET (VOIDmode,
                           output_rtx[i],
                           gen_rtx_ASM_OPERANDS
-                          (VOIDmode,
+                          (GET_MODE (output_rtx[i]),
                            TREE_STRING_POINTER (string),
                            TREE_STRING_POINTER (TREE_PURPOSE (tail)),
                            i, argvec, constraints,
@@ -1907,12 +1921,14 @@ expand_expr_stmt (exp)
      except inside a ({...}) where they may be useful.  */
   if (expr_stmts_for_value == 0 && exp != error_mark_node)
     {
-      if (! TREE_SIDE_EFFECTS (exp)
-         && (extra_warnings || warn_unused_value)
-         && !(TREE_CODE (exp) == CONVERT_EXPR
-              && VOID_TYPE_P (TREE_TYPE (exp))))
-       warning_with_file_and_line (emit_filename, emit_lineno,
-                                   "statement with no effect");
+      if (! TREE_SIDE_EFFECTS (exp))
+       {
+         if ((extra_warnings || warn_unused_value)
+             && !(TREE_CODE (exp) == CONVERT_EXPR
+                  && VOID_TYPE_P (TREE_TYPE (exp))))
+           warning_with_file_and_line (emit_filename, emit_lineno,
+                                       "statement with no effect");
+       }
       else if (warn_unused_value)
        warn_if_unused_value (exp);
     }
@@ -1922,11 +1938,14 @@ expand_expr_stmt (exp)
   if (expr_stmts_for_value && TREE_CODE (TREE_TYPE (exp)) == FUNCTION_TYPE)
     exp = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (exp)), exp);
 
-  last_expr_type = TREE_TYPE (exp);
+  /* The call to `expand_expr' could cause last_expr_type and
+     last_expr_value to get reset.  Therefore, we set last_expr_value
+     and last_expr_type *after* calling expand_expr.  */
   last_expr_value = expand_expr (exp,
                                 (expr_stmts_for_value
                                  ? NULL_RTX : const0_rtx),
                                 VOIDmode, 0);
+  last_expr_type = TREE_TYPE (exp);
 
   /* If all we do is reference a volatile value in memory,
      copy it to a register to be sure it is actually touched.  */
@@ -1974,6 +1993,16 @@ warn_if_unused_value (exp)
   if (TREE_USED (exp))
     return 0;
 
+  /* Don't warn about void constructs.  This includes casting to void,
+     void function calls, and statement expressions with a final cast
+     to void.  */
+  if (VOID_TYPE_P (TREE_TYPE (exp)))
+    return 0;
+
+  /* If this is an expression with side effects, don't warn.  */
+  if (TREE_SIDE_EFFECTS (exp))
+    return 0;
+
   switch (TREE_CODE (exp))
     {
     case PREINCREMENT_EXPR:
@@ -1989,9 +2018,6 @@ warn_if_unused_value (exp)
     case TRY_CATCH_EXPR:
     case WITH_CLEANUP_EXPR:
     case EXIT_EXPR:
-      /* We don't warn about COND_EXPR because it may be a useful
-        construct if either arm contains a side effect.  */
-    case COND_EXPR:
       return 0;
 
     case BIND_EXPR:
@@ -2019,9 +2045,6 @@ warn_if_unused_value (exp)
     case NOP_EXPR:
     case CONVERT_EXPR:
     case NON_LVALUE_EXPR:
-      /* Don't warn about values cast to void.  */
-      if (VOID_TYPE_P (TREE_TYPE (exp)))
-       return 0;
       /* Don't warn about conversions not explicit in the user's program.  */
       if (TREE_NO_UNUSED_WARNING (exp))
        return 0;
@@ -2084,14 +2107,11 @@ clear_last_expr ()
 tree
 expand_start_stmt_expr ()
 {
-  int momentary;
   tree t;
 
   /* Make the RTL_EXPR node temporary, not momentary,
      so that rtl_expr_chain doesn't become garbage.  */
-  momentary = suspend_momentary ();
   t = make_node (RTL_EXPR);
-  resume_momentary (momentary);
   do_pending_stack_adjust ();
   start_sequence_for_rtl_expr (t);
   NO_DEFER_POP;
@@ -2285,6 +2305,30 @@ expand_start_loop_continue_elsewhere (exit_flag)
   return thisloop;
 }
 
+/* Begin a null, aka do { } while (0) "loop".  But since the contents
+   of said loop can still contain a break, we must frob the loop nest.  */
+
+struct nesting *
+expand_start_null_loop ()
+{
+  register struct nesting *thisloop = ALLOC_NESTING ();
+
+  /* Make an entry on loop_stack for the loop we are entering.  */
+
+  thisloop->next = loop_stack;
+  thisloop->all = nesting_stack;
+  thisloop->depth = ++nesting_depth;
+  thisloop->data.loop.start_label = emit_note (NULL, NOTE_INSN_DELETED);
+  thisloop->data.loop.end_label = gen_label_rtx ();
+  thisloop->data.loop.alt_end_label = NULL_RTX;
+  thisloop->data.loop.continue_label = thisloop->data.loop.end_label;
+  thisloop->exit_label = thisloop->data.loop.end_label;
+  loop_stack = thisloop;
+  nesting_stack = thisloop;
+
+  return thisloop;
+}
+
 /* Specify the continuation point for a loop started with
    expand_start_loop_continue_elsewhere.
    Use this at the point in the code to which a continue statement
@@ -2611,6 +2655,19 @@ expand_end_loop ()
   last_expr_type = 0;
 }
 
+/* Finish a null loop, aka do { } while (0).  */
+
+void
+expand_end_null_loop ()
+{
+  do_pending_stack_adjust ();
+  emit_label (loop_stack->data.loop.end_label);
+
+  POPSTACK (loop_stack);
+
+  last_expr_type = 0;
+}
+
 /* Generate a jump to the current loop's continue-point.
    This is usually the top of the loop, but may be specified
    explicitly elsewhere.  If not currently inside a loop,
@@ -2963,6 +3020,12 @@ expand_return (retval)
       rtx result_val = expand_expr (retval_rhs, NULL_RTX, VOIDmode, 0);
       enum machine_mode tmpmode, result_reg_mode;
 
+      if (bytes == 0)
+       {
+         expand_null_return ();
+         return;
+       }
+
       /* Structures whose size is not a multiple of a word are aligned
         to the least significant byte (to the right).  On a BYTES_BIG_ENDIAN
         machine, this means we must skip the empty high order bytes when
@@ -3010,15 +3073,12 @@ expand_return (retval)
       /* Find the smallest integer mode large enough to hold the
         entire structure and use that mode instead of BLKmode
         on the USE insn for the return register.   */
-      bytes = int_size_in_bytes (TREE_TYPE (retval_rhs));
       for (tmpmode = GET_CLASS_NARROWEST_MODE (MODE_INT);
           tmpmode != VOIDmode;
           tmpmode = GET_MODE_WIDER_MODE (tmpmode))
-       {
-         /* Have we found a large enough mode?  */
-         if (GET_MODE_SIZE (tmpmode) >= bytes)
-           break;
-       }
+       /* Have we found a large enough mode?  */
+       if (GET_MODE_SIZE (tmpmode) >= bytes)
+         break;
 
       /* No suitable mode found.  */
       if (tmpmode == VOIDmode)
@@ -3050,8 +3110,10 @@ expand_return (retval)
     {
       /* Calculate the return value into a temporary (usually a pseudo
          reg).  */
-      val = assign_temp (TREE_TYPE (DECL_RESULT (current_function_decl)),
-                        0, 0, 1);
+      tree ot = TREE_TYPE (DECL_RESULT (current_function_decl));
+      tree nt = build_qualified_type (ot, TYPE_QUALS (ot) | TYPE_QUAL_CONST);
+
+      val = assign_temp (nt, 0, 0, 1);
       val = expand_expr (retval_rhs, val, GET_MODE (val), 0);
       val = force_not_mem (val);
       emit_queue ();
@@ -3772,12 +3834,13 @@ expand_decl (decl)
 
   if (type == error_mark_node)
     DECL_RTL (decl) = gen_rtx_MEM (BLKmode, const0_rtx);
+
   else if (DECL_SIZE (decl) == 0)
     /* Variable with incomplete type.  */
     {
       if (DECL_INITIAL (decl) == 0)
        /* Error message was already done; now avoid a crash.  */
-       DECL_RTL (decl) = assign_stack_temp (DECL_MODE (decl), 0, 1);
+       DECL_RTL (decl) = gen_rtx_MEM (BLKmode, const0_rtx);
       else
        /* An initializer is going to decide the size of this array.
           Until we know the size, represent its address with a reg.  */
@@ -3791,7 +3854,6 @@ expand_decl (decl)
           && !(flag_float_store
                && TREE_CODE (type) == REAL_TYPE)
           && ! TREE_THIS_VOLATILE (decl)
-          && ! TREE_ADDRESSABLE (decl)
           && (DECL_REGISTER (decl) || optimize)
           /* if -fcheck-memory-usage, check all variables.  */
           && ! current_function_check_memory_usage)
@@ -3809,6 +3871,10 @@ expand_decl (decl)
                          TYPE_ALIGN (TREE_TYPE (TREE_TYPE (decl))));
 
       maybe_set_unchanging (DECL_RTL (decl), decl);
+
+      /* If something wants our address, try to use ADDRESSOF.  */
+      if (TREE_ADDRESSABLE (decl))
+       put_var_into_stack (decl);
     }
 
   else if (TREE_CODE (DECL_SIZE_UNIT (decl)) == INTEGER_CST
@@ -3989,10 +4055,6 @@ expand_decl_cleanup (decl, cleanup)
 
          emit_move_insn (flag, const1_rtx);
 
-         /* All cleanups must be on the function_obstack.  */
-         push_obstacks_nochange ();
-         resume_temporary_allocation ();
-
          cond = build_decl (VAR_DECL, NULL_TREE, type_for_mode (word_mode, 1));
          DECL_RTL (cond) = flag;
 
@@ -4002,18 +4064,12 @@ expand_decl_cleanup (decl, cleanup)
                           cleanup, integer_zero_node);
          cleanup = fold (cleanup);
 
-         pop_obstacks ();
-
          cleanups = thisblock->data.block.cleanup_ptr;
        }
 
-      /* All cleanups must be on the function_obstack.  */
-      push_obstacks_nochange ();
-      resume_temporary_allocation ();
       cleanup = unsave_expr (cleanup);
-      pop_obstacks ();
 
-      t = *cleanups = temp_tree_cons (decl, cleanup, *cleanups);
+      t = *cleanups = tree_cons (decl, cleanup, *cleanups);
 
       if (! cond_context)
        /* If this block has a cleanup, it belongs in stack_block_stack.  */
@@ -4105,15 +4161,11 @@ expand_dcc_cleanup (decl)
 
   /* Record the cleanup for the dynamic handler chain.  */
 
-  /* All cleanups must be on the function_obstack.  */
-  push_obstacks_nochange ();
-  resume_temporary_allocation ();
   cleanup = make_node (POPDCC_EXPR);
-  pop_obstacks ();
 
   /* Add the cleanup in a manner similar to expand_decl_cleanup.  */
   thisblock->data.block.cleanups
-    = temp_tree_cons (decl, cleanup, thisblock->data.block.cleanups);
+    = tree_cons (decl, cleanup, thisblock->data.block.cleanups);
 
   /* If this block has a cleanup, it belongs in stack_block_stack.  */
   stack_block_stack = thisblock;
@@ -4147,15 +4199,11 @@ expand_dhc_cleanup (decl)
 
   /* Record the cleanup for the dynamic handler chain.  */
 
-  /* All cleanups must be on the function_obstack.  */
-  push_obstacks_nochange ();
-  resume_temporary_allocation ();
   cleanup = make_node (POPDHC_EXPR);
-  pop_obstacks ();
 
   /* Add the cleanup in a manner similar to expand_decl_cleanup.  */
   thisblock->data.block.cleanups
-    = temp_tree_cons (decl, cleanup, thisblock->data.block.cleanups);
+    = tree_cons (decl, cleanup, thisblock->data.block.cleanups);
 
   /* If this block has a cleanup, it belongs in stack_block_stack.  */
   stack_block_stack = thisblock;
@@ -4230,8 +4278,8 @@ expand_anon_union_decl (decl, cleanup, decl_elts)
 
       if (cleanup != 0)
        thisblock->data.block.cleanups
-         = temp_tree_cons (decl_elt, cleanup_elt,
-                           thisblock->data.block.cleanups);
+         = tree_cons (decl_elt, cleanup_elt,
+                      thisblock->data.block.cleanups);
     }
 }
 \f
@@ -4422,7 +4470,6 @@ expand_start_case (exit_flag, expr, type, printname)
   thiscase->data.case_stmt.index_expr = expr;
   thiscase->data.case_stmt.nominal_type = type;
   thiscase->data.case_stmt.default_label = 0;
-  thiscase->data.case_stmt.num_ranges = 0;
   thiscase->data.case_stmt.printname = printname;
   thiscase->data.case_stmt.line_number_status = force_line_numbers ();
   case_stack = thiscase;
@@ -4460,7 +4507,6 @@ expand_start_case_dummy ()
   thiscase->data.case_stmt.start = 0;
   thiscase->data.case_stmt.nominal_type = 0;
   thiscase->data.case_stmt.default_label = 0;
-  thiscase->data.case_stmt.num_ranges = 0;
   case_stack = thiscase;
   nesting_stack = thiscase;
   start_cleanup_deferral ();
@@ -4576,21 +4622,7 @@ pushcase (value, converter, label, duplicate)
          || ! int_fits_type_p (value, index_type)))
     return 3;
 
-  /* Fail if this is a duplicate or overlaps another entry.  */
-  if (value == 0)
-    {
-      if (case_stack->data.case_stmt.default_label != 0)
-       {
-         *duplicate = case_stack->data.case_stmt.default_label;
-         return 2;
-       }
-      case_stack->data.case_stmt.default_label = label;
-    }
-  else
-    return add_case_node (value, value, label, duplicate);
-
-  expand_label (label);
-  return 0;
+  return add_case_node (value, value, label, duplicate);
 }
 
 /* Like pushcase but this case applies to all values between VALUE1 and
@@ -4666,7 +4698,7 @@ pushcase_range (value1, value2, converter, label, duplicate)
    into case_stack->data.case_stmt.case_list.  Use an AVL tree to avoid
    slowdown for large switch statements.  */
 
-static int
+int
 add_case_node (low, high, label, duplicate)
      tree low, high;
      tree label;
@@ -4674,6 +4706,25 @@ add_case_node (low, high, label, duplicate)
 {
   struct case_node *p, **q, *r;
 
+  /* If there's no HIGH value, then this is not a case range; it's
+     just a simple case label.  But that's just a degenerate case
+     range.  */
+  if (!high)
+    high = low;
+
+  /* Handle default labels specially.  */
+  if (!high && !low)
+    {
+      if (case_stack->data.case_stmt.default_label != 0)
+       {
+         *duplicate = case_stack->data.case_stmt.default_label;
+         return 2;
+       }
+      case_stack->data.case_stmt.default_label = label;
+      expand_label (label);
+      return 0;
+    }
+
   q = &case_stack->data.case_stmt.case_list;
   p = *q;
 
@@ -4697,22 +4748,16 @@ add_case_node (low, high, label, duplicate)
        }
     }
 
-  /* Add this label to the chain, and succeed.
-     Copy LOW, HIGH so they are on temporary rather than momentary
-     obstack and will thus survive till the end of the case statement.  */
+  /* Add this label to the chain, and succeed.  */
 
-  r = (struct case_node *) oballoc (sizeof (struct case_node));
-  r->low = copy_node (low);
+  r = (struct case_node *) xmalloc (sizeof (struct case_node));
+  r->low = low;
 
   /* If the bounds are equal, turn this into the one-value case.  */
-
   if (tree_int_cst_equal (low, high))
     r->high = r->low;
   else
-    {
-      r->high = copy_node (high);
-      case_stack->data.case_stmt.num_ranges++;
-    }
+    r->high = high;
 
   r->code_label = label;
   expand_label (label);
@@ -5239,6 +5284,20 @@ check_for_full_enumeration_handling (type)
 #endif /* 0 */
 }
 
+/* Free CN, and its children.  */
+
+static void 
+free_case_nodes (cn)
+     case_node_ptr cn;
+{
+  if (cn) 
+    {
+      free_case_nodes (cn->left);
+      free_case_nodes (cn->right);
+      free (cn);
+    }
+}
+
 \f
 /* Terminate a case (Pascal) or switch (C) statement
    in which ORIG_INDEX is the expression to be tested.
@@ -5571,7 +5630,7 @@ expand_end_case (orig_index)
 
          ncases = TREE_INT_CST_LOW (range) + 1;
          labelvec = (rtx *) alloca (ncases * sizeof (rtx));
-         bzero ((char *) labelvec, ncases * sizeof (rtx));
+         memset ((char *) labelvec, 0, ncases * sizeof (rtx));
 
          for (n = thiscase->data.case_stmt.case_list; n; n = n->right)
            {
@@ -5626,6 +5685,7 @@ expand_end_case (orig_index)
   if (thiscase->exit_label)
     emit_label (thiscase->exit_label);
 
+  free_case_nodes (case_stack->data.case_stmt.case_list);
   POPSTACK (case_stack);
 
   free_temp_slots ();
@@ -5704,7 +5764,7 @@ static int
 estimate_case_costs (node)
      case_node_ptr node;
 {
-  tree min_ascii = build_int_2 (-1, -1);
+  tree min_ascii = integer_minus_one_node;
   tree max_ascii = convert (TREE_TYPE (node->high), build_int_2 (127, 0));
   case_node_ptr n;
   int i;
@@ -5712,27 +5772,27 @@ estimate_case_costs (node)
   /* If we haven't already made the cost table, make it now.  Note that the
      lower bound of the table is -1, not zero.  */
 
-  if (cost_table == NULL)
+  if (! cost_table_initialized)
     {
-      cost_table = cost_table_ + 1;
+      cost_table_initialized = 1;
 
       for (i = 0; i < 128; i++)
        {
          if (ISALNUM (i))
-           cost_table[i] = 16;
+           COST_TABLE (i) = 16;
          else if (ISPUNCT (i))
-           cost_table[i] = 8;
+           COST_TABLE (i) = 8;
          else if (ISCNTRL (i))
-           cost_table[i] = -1;
+           COST_TABLE (i) = -1;
        }
 
-      cost_table[' '] = 8;
-      cost_table['\t'] = 4;
-      cost_table['\0'] = 4;
-      cost_table['\n'] = 2;
-      cost_table['\f'] = 1;
-      cost_table['\v'] = 1;
-      cost_table['\b'] = 1;
+      COST_TABLE (' ') = 8;
+      COST_TABLE ('\t') = 4;
+      COST_TABLE ('\0') = 4;
+      COST_TABLE ('\n') = 2;
+      COST_TABLE ('\f') = 1;
+      COST_TABLE ('\v') = 1;
+      COST_TABLE ('\b') = 1;
     }
 
   /* See if all the case expressions look like text.  It is text if the
@@ -5748,7 +5808,7 @@ estimate_case_costs (node)
 
       for (i = (HOST_WIDE_INT) TREE_INT_CST_LOW (n->low);
           i <= (HOST_WIDE_INT) TREE_INT_CST_LOW (n->high); i++)
-       if (cost_table[i] < 0)
+       if (COST_TABLE (i) < 0)
          return 0;
     }
 
@@ -5839,11 +5899,11 @@ balance_case_nodes (head, parent)
            {
              ranges++;
              if (use_cost_table)
-               cost += cost_table[TREE_INT_CST_LOW (np->high)];
+               cost += COST_TABLE (TREE_INT_CST_LOW (np->high));
            }
 
          if (use_cost_table)
-           cost += cost_table[TREE_INT_CST_LOW (np->low)];
+           cost += COST_TABLE (TREE_INT_CST_LOW (np->low));
 
          i++;
          np = np->right;
@@ -5864,8 +5924,8 @@ balance_case_nodes (head, parent)
                {
                  /* Skip nodes while their cost does not reach that amount.  */
                  if (!tree_int_cst_equal ((*npp)->low, (*npp)->high))
-                   i -= cost_table[TREE_INT_CST_LOW ((*npp)->high)];
-                 i -= cost_table[TREE_INT_CST_LOW ((*npp)->low)];
+                   i -= COST_TABLE (TREE_INT_CST_LOW ((*npp)->high));
+                 i -= COST_TABLE (TREE_INT_CST_LOW ((*npp)->low));
                  if (i <= 0)
                    break;
                  npp = &(*npp)->right;
@@ -6197,7 +6257,7 @@ emit_case_nodes (index, node, default_label, index_type)
             a branch-greater-than will get us to the default
             label correctly.  */
          if (use_cost_table
-             && cost_table[TREE_INT_CST_LOW (node->high)] < 12)
+             && COST_TABLE (TREE_INT_CST_LOW (node->high)) < 12)
            ;
 #endif /* 0 */
          if (node->left->left || node->left->right