OSDN Git Service

* init.c (build_new): Allow enumeration types for the array-bounds
[pf3gnuchains/gcc-fork.git] / gcc / stmt.c
index 06242ce..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.
 
@@ -783,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.  */
@@ -836,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);
@@ -1748,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;
@@ -1983,6 +1999,10 @@ warn_if_unused_value (exp)
   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:
@@ -2058,10 +2078,6 @@ warn_if_unused_value (exp)
          && TREE_THIS_VOLATILE (exp))
        return 0;
 
-      /* If this is an expression with side effects, don't warn.  */
-      if (TREE_SIDE_EFFECTS (exp))
-       return 0;
-
       /* If this is an expression which has no operands, there is no value
         to be unused.  There are no such language-independent codes,
         but front ends may define such.  */
@@ -3004,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
@@ -3051,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)
@@ -3091,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 ();
@@ -3813,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.  */
@@ -4726,18 +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 *) xmalloc (sizeof (struct case_node));
-  r->low = copy_node (low);
+  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);
+    r->high = high;
 
   r->code_label = label;
   expand_label (label);
@@ -5744,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;
@@ -5752,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
@@ -5788,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;
     }
 
@@ -5879,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;
@@ -5904,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;
@@ -6237,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