/* 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.
#include "ggc.h"
#include "hashtab.h"
#include "output.h"
-#include "defaults.h"
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
}
\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)
register int length;
register int i;
int fro;
+ int constant;
VA_START (p, 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. */
TREE_SIDE_EFFECTS (t) = 1;
if (!TREE_READONLY (arg0))
TREE_READONLY (t) = 0;
+ if (!TREE_CONSTANT (arg0))
+ constant = 0;
}
if (arg1 && fro > 1)
TREE_SIDE_EFFECTS (t) = 1;
if (!TREE_READONLY (arg1))
TREE_READONLY (t) = 0;
+ if (!TREE_CONSTANT (arg1))
+ constant = 0;
}
}
else if (length == 1)
{
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;
}
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);
break;
default:
+ if (TREE_CODE_CLASS (code) == '1' && node && TREE_CONSTANT (node))
+ TREE_CONSTANT (t) = 1;
break;
}
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. */
/* 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);