This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
(C++) Patch to bot_manip
- To: gcc-patches at gcc dot gnu dot org
- Subject: (C++) Patch to bot_manip
- From: Jason Merrill <jason at redhat dot com>
- Date: Wed, 30 Aug 2000 16:37:56 -0700
We were failing to unshare default argument trees properly for a
couple of reasons:
1) We thought that something with no side effects wasn't worth
copying. This is wrong for, say, an ADDR_EXPR of the VAR_DECL from
a TARGET_EXPR.
2) We were failing to call break_out_target_exprs for TARGET_EXPR
initializers other than AGGR_INIT_EXPRs, and then assuming we had.
Fixes g++.other/defarg5.C.
2000-08-30 Jason Merrill <jason@redhat.com>
* tree.c (bot_manip): Check TREE_CONSTANT rather than
!TREE_SIDE_EFFECTS. Call break_out_target_exprs and
build_target_expr_with_type for the non-AGGR_INIT_EXPR case.
Index: tree.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/tree.c,v
retrieving revision 1.209
diff -c -p -r1.209 tree.c
*** tree.c 2000/08/25 19:07:56 1.209
--- tree.c 2000/08/30 23:26:29
*************** bot_manip (tp, walk_subtrees, data)
*** 1649,1661 ****
splay_tree target_remap = ((splay_tree) data);
tree t = *tp;
! if (TREE_CODE (t) != TREE_LIST && ! TREE_SIDE_EFFECTS (t))
{
! /* There can't be any TARGET_EXPRs below this point. */
*walk_subtrees = 0;
return NULL_TREE;
}
! else if (TREE_CODE (t) == TARGET_EXPR)
{
tree u;
--- 1649,1663 ----
splay_tree target_remap = ((splay_tree) data);
tree t = *tp;
! if (TREE_CONSTANT (t))
{
! /* There can't be any TARGET_EXPRs or their slot variables below
! this point. We used to check !TREE_SIDE_EFFECTS, but then we
! failed to copy an ADDR_EXPR of the slot VAR_DECL. */
*walk_subtrees = 0;
return NULL_TREE;
}
! if (TREE_CODE (t) == TARGET_EXPR)
{
tree u;
*************** bot_manip (tp, walk_subtrees, data)
*** 1667,1679 ****
}
else
{
! tree var;
!
! u = copy_node (t);
! var = build (VAR_DECL, TREE_TYPE (t));
! DECL_CONTEXT (var) = current_function_decl;
! layout_decl (var, 0);
! TREE_OPERAND (u, 0) = var;
}
/* Map the old variable to the new one. */
--- 1669,1676 ----
}
else
{
! u = build_target_expr_with_type
! (break_out_target_exprs (TREE_OPERAND (t, 1)), TREE_TYPE (t));
}
/* Map the old variable to the new one. */