(C++) tree inlining patch RFD
Jason Merrill
jason@cygnus.com
Wed Dec 15 11:47:00 GMT 1999
This patch fixes block structure problems with g++.other/inline3.C. We
were expanding inline the call to operator[] before we saw the SCOPE_STMT
for the for-scope; the for block then ended up nested inside the block for
the inlined function.
I haven't checked this in because I don't really see this as a solution;
the problem is that the way we're handling blocks is extremely fragile.
I'm running into a similar problem in libstdc++/tests/tlist.cc where the
block for a cleanup for a TARGET_EXPR is inserted before the block where
the temporary in question appears. Mark, do you have any thoughts?
1999-12-15 Jason Merrill <jason@casey.cygnus.com>
* tree.c (walk_tree): Walk operand subtrees in forward order.
Index: tree.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/tree.c,v
retrieving revision 1.168
diff -c -p -r1.168 tree.c
*** tree.c 1999/12/15 09:51:24 1.168
--- tree.c 1999/12/15 19:35:22
*************** walk_tree (tp, func, data)
*** 1623,1643 ****
|| TREE_CODE_CLASS (code) == 'r'
|| TREE_CODE_CLASS (code) == 's')
{
! int i;
/* Walk over all the sub-trees of this operand. */
! i = first_rtl_op (code) - 1;
/* TARGET_EXPRs are peculiar: operands 1 and 3 can be the same.
But, we only want to walk once. */
if (code == TARGET_EXPR
&& TREE_OPERAND (*tp, 3) == TREE_OPERAND (*tp, 1))
! --i;
! /* Go through the subtrees. */
! while (i >= 0)
! {
! WALK_SUBTREE (TREE_OPERAND (*tp, i));
! --i;
! }
/* For statements, we also walk the chain so that we cover the
entire statement tree. */
--- 1623,1641 ----
|| TREE_CODE_CLASS (code) == 'r'
|| TREE_CODE_CLASS (code) == 's')
{
! int i, len;
/* Walk over all the sub-trees of this operand. */
! len = first_rtl_op (code);
/* TARGET_EXPRs are peculiar: operands 1 and 3 can be the same.
But, we only want to walk once. */
if (code == TARGET_EXPR
&& TREE_OPERAND (*tp, 3) == TREE_OPERAND (*tp, 1))
! --len;
! /* Go through the subtrees. We need to do this in forward order so
! that the scope of a FOR_EXPR is handled properly. */
! for (i = 0; i < len; ++i)
! WALK_SUBTREE (TREE_OPERAND (*tp, i));
/* For statements, we also walk the chain so that we cover the
entire statement tree. */
More information about the Gcc-patches
mailing list