This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH for bogosity in `build'
- To: gcc-patches at gcc dot gnu dot org
- Subject: PATCH for bogosity in `build'
- From: "Mark P. Mitchell" <mark at codesourcery dot com>
- Date: Sat, 2 Oct 1999 02:54:29 -0600 (MDT)
- Reply-to: mark at codesourcery dot com
This appears to be a long-standing bug in `build'. Some operands to
tree nodes are not themselves trees. For example, an RTL_EXPR has RTL
operands. That means that we shouldn't be using TREE_SIDE_EFFECTS and
TREE_RAISES on the operands indiscriminately. This bug started
causing crashes on IRIX6, probaby because the C++ front-end now tends
to generate more RTL_EXPRs than before.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
Sat Oct 2 02:48:21 1999 Mark P. Mitchell <mark@codesourcery.com>
* tree.c (build): Don't look at TREE_SIDE_EFFECTS or TREE_RAISES
for non-trees.
(build1): Likewise.
Index: tree.c
===================================================================
RCS file: /cvs/egcs/egcs/gcc/tree.c,v
retrieving revision 1.93
diff -c -p -r1.93 tree.c
*** tree.c 1999/09/22 21:37:20 1.93
--- tree.c 1999/10/02 08:47:14
*************** build VPROTO((enum tree_code code, tree
*** 2990,2995 ****
--- 2990,2996 ----
register tree t;
register int length;
register int i;
+ int fro;
VA_START (p, tt);
*************** build VPROTO((enum tree_code code, tree
*** 3002,3007 ****
--- 3003,3014 ----
length = tree_code_length[(int) code];
TREE_TYPE (t) = tt;
+ /* Below, we automatically set TREE_SIDE_EFFECTS and TREE_RAISED for
+ the result based on those same flags for the arguments. But, if
+ the arguments aren't really even `tree' expressions, we shouldn't
+ be trying to do this. */
+ fro = first_rtl_op (code);
+
if (length == 2)
{
/* This is equivalent to the loop below, but faster. */
*************** build VPROTO((enum tree_code code, tree
*** 3009,3019 ****
register tree arg1 = va_arg (p, tree);
TREE_OPERAND (t, 0) = arg0;
TREE_OPERAND (t, 1) = arg1;
! if ((arg0 && TREE_SIDE_EFFECTS (arg0))
! || (arg1 && TREE_SIDE_EFFECTS (arg1)))
! TREE_SIDE_EFFECTS (t) = 1;
! TREE_RAISES (t)
! = (arg0 && TREE_RAISES (arg0)) || (arg1 && TREE_RAISES (arg1));
}
else if (length == 1)
{
--- 3016,3035 ----
register tree arg1 = va_arg (p, tree);
TREE_OPERAND (t, 0) = arg0;
TREE_OPERAND (t, 1) = arg1;
! if (arg0 && fro > 0)
! {
! if (TREE_SIDE_EFFECTS (arg0))
! TREE_SIDE_EFFECTS (t) = 1;
! if (TREE_RAISES (arg0))
! TREE_RAISES (t) = 1;
! }
! if (arg1 && fro > 1)
! {
! if (TREE_SIDE_EFFECTS (arg1))
! TREE_SIDE_EFFECTS (t) = 1;
! if (TREE_RAISES (arg1))
! TREE_RAISES (t) = 1;
! }
}
else if (length == 1)
{
*************** build VPROTO((enum tree_code code, tree
*** 3023,3031 ****
if (TREE_CODE_CLASS (code) != 's')
abort ();
TREE_OPERAND (t, 0) = arg0;
! if (arg0 && TREE_SIDE_EFFECTS (arg0))
! TREE_SIDE_EFFECTS (t) = 1;
! TREE_RAISES (t) = (arg0 && TREE_RAISES (arg0));
}
else
{
--- 3039,3050 ----
if (TREE_CODE_CLASS (code) != 's')
abort ();
TREE_OPERAND (t, 0) = arg0;
! if (fro > 0)
! {
! if (arg0 && TREE_SIDE_EFFECTS (arg0))
! TREE_SIDE_EFFECTS (t) = 1;
! TREE_RAISES (t) = (arg0 && TREE_RAISES (arg0));
! }
}
else
{
*************** build VPROTO((enum tree_code code, tree
*** 3033,3039 ****
{
register tree operand = va_arg (p, tree);
TREE_OPERAND (t, i) = operand;
! if (operand)
{
if (TREE_SIDE_EFFECTS (operand))
TREE_SIDE_EFFECTS (t) = 1;
--- 3052,3058 ----
{
register tree operand = va_arg (p, tree);
TREE_OPERAND (t, i) = operand;
! if (operand && fro > i)
{
if (TREE_SIDE_EFFECTS (operand))
TREE_SIDE_EFFECTS (t) = 1;
*************** build1 (code, type, node)
*** 3090,3096 ****
TREE_PERMANENT (t) = 1;
TREE_OPERAND (t, 0) = node;
! if (node)
{
if (TREE_SIDE_EFFECTS (node))
TREE_SIDE_EFFECTS (t) = 1;
--- 3109,3115 ----
TREE_PERMANENT (t) = 1;
TREE_OPERAND (t, 0) = node;
! if (node && first_rtl_op (code) != 0)
{
if (TREE_SIDE_EFFECTS (node))
TREE_SIDE_EFFECTS (t) = 1;