OSDN Git Service

* init.c (build_new): Allow enumeration types for the array-bounds
[pf3gnuchains/gcc-fork.git] / gcc / tree.c
index a836b99..4ef1441 100644 (file)
@@ -1,6 +1,6 @@
 /* Language-independent node constructors for parse phase of GNU compiler.
    Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000 Free Software Foundation, Inc.
+   1999, 2000, 2001 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -44,7 +44,6 @@ Boston, MA 02111-1307, USA.  */
 #include "ggc.h"
 #include "hashtab.h"
 #include "output.h"
-#include "defaults.h"
 
 #define obstack_chunk_alloc xmalloc
 #define obstack_chunk_free free
@@ -469,10 +468,7 @@ make_lang_type (code)
 }
 \f
 /* Return a new node with the same contents as NODE except that its
-   TREE_CHAIN is zero and it has a fresh uid.  Unlike make_node, this
-   function always performs the allocation on the CURRENT_OBSTACK;
-   it's up to the caller to pick the right obstack before calling this
-   function.  */
+   TREE_CHAIN is zero and it has a fresh uid.  */
 
 tree
 copy_node (node)
@@ -2327,6 +2323,7 @@ build VPARAMS ((enum tree_code code, tree tt, ...))
   register int length;
   register int i;
   int fro;
+  int constant;
 
   VA_START (p, tt);
 
@@ -2345,6 +2342,13 @@ build VPARAMS ((enum tree_code code, tree tt, ...))
      to do this.  */
   fro = first_rtl_op (code);
 
+  /* Expressions without side effects may be constant if their
+     arguments are as well.  */
+  constant = (TREE_CODE_CLASS (code) == '<'
+             || TREE_CODE_CLASS (code) == '1'
+             || TREE_CODE_CLASS (code) == '2'
+             || TREE_CODE_CLASS (code) == 'c');
+
   if (length == 2)
     {
       /* This is equivalent to the loop below, but faster.  */
@@ -2360,6 +2364,8 @@ build VPARAMS ((enum tree_code code, tree tt, ...))
            TREE_SIDE_EFFECTS (t) = 1;
          if (!TREE_READONLY (arg0))
            TREE_READONLY (t) = 0;
+         if (!TREE_CONSTANT (arg0))
+           constant = 0;
        }
 
       if (arg1 && fro > 1)
@@ -2368,6 +2374,8 @@ build VPARAMS ((enum tree_code code, tree tt, ...))
            TREE_SIDE_EFFECTS (t) = 1;
          if (!TREE_READONLY (arg1))
            TREE_READONLY (t) = 0;
+         if (!TREE_CONSTANT (arg1))
+           constant = 0;
        }
     }
   else if (length == 1)
@@ -2394,10 +2402,14 @@ build VPARAMS ((enum tree_code code, tree tt, ...))
            {
              if (TREE_SIDE_EFFECTS (operand))
                TREE_SIDE_EFFECTS (t) = 1;
+             if (!TREE_CONSTANT (operand))
+               constant = 0;
            }
        }
     }
   va_end (p);
+
+  TREE_CONSTANT (t) = constant;
   return t;
 }
 
@@ -2424,6 +2436,13 @@ build1 (code, type, node)
     kind = e_kind;
 #endif
 
+#ifdef ENABLE_CHECKING
+  if (TREE_CODE_CLASS (code) == '2' 
+      || TREE_CODE_CLASS (code) == '<'
+      || TREE_CODE_LENGTH (code) != 1)
+    abort ();
+#endif /* ENABLE_CHECKING */
+
   length = sizeof (struct tree_exp);
 
   t = ggc_alloc_tree (length);
@@ -2463,6 +2482,8 @@ build1 (code, type, node)
       break;
 
     default:
+      if (TREE_CODE_CLASS (code) == '1' && node && TREE_CONSTANT (node))
+       TREE_CONSTANT (t) = 1;
       break;
     }
 
@@ -2501,36 +2522,6 @@ build_nt VPARAMS ((enum tree_code code, ...))
   return t;
 }
 
-/* Similar to `build_nt', except we build
-   on the temp_decl_obstack, regardless.  */
-
-tree
-build_parse_node VPARAMS ((enum tree_code code, ...))
-{
-#ifndef ANSI_PROTOTYPES
-  enum tree_code code;
-#endif
-  va_list p;
-  register tree t;
-  register int length;
-  register int i;
-
-  VA_START (p, code);
-
-#ifndef ANSI_PROTOTYPES
-  code = va_arg (p, enum tree_code);
-#endif
-
-  t = make_node (code);
-  length = TREE_CODE_LENGTH (code);
-
-  for (i = 0; i < length; i++)
-    TREE_OPERAND (t, i) = va_arg (p, tree);
-
-  va_end (p);
-  return t;
-}
-
 #if 0
 /* Commented out because this wants to be done very
    differently.  See cp-lex.c.  */
@@ -4783,6 +4774,7 @@ build_common_tree_nodes_2 (short_double)
   /* Define these next since types below may used them.  */
   integer_zero_node = build_int_2 (0, 0);
   integer_one_node = build_int_2 (1, 0);
+  integer_minus_one_node = build_int_2 (-1, -1);
 
   size_zero_node = size_int (0);
   size_one_node = size_int (1);