[C++ PATCH] Fix g++.jason/pmf7.C on i586-pc-linux-gnu
Glen Nakamura
glen@imodulo.com
Sun Oct 6 09:38:00 GMT 2002
Aloha,
The following patch fixes the g++.jason/pmf7.C and g++.jason/template26.C
testsuite failures on i586-pc-linux-gnu for mainline. The problem is
that the initial expand_expr() of a SAVE_EXPR occurs within a COND_EXPR which
violates tree.c:save_expr() usage rules. The code that detected this case
in cp/typeck.c:get_member_function_from_ptrfunc() is broken because the
value of instance_ptr is modified after the call to save_expr(),
which causes (TREE_CODE (instance_ptr) == SAVE_EXPR) to always be false.
2002-10-06 Glen Nakamura <glen@imodulo.com>
* typeck.c (get_member_function_from_ptrfunc): Make sure that a
SAVE_EXPR for instance_ptr doesn't get evaluated first inside one
of the branches of a COND_EXPR.
Index: cp/typeck.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/cp/typeck.c,v
retrieving revision 1.430
diff -c -3 -p -r1.430 typeck.c
*** cp/typeck.c 30 Sep 2002 16:52:15 -0000 1.430
--- cp/typeck.c 6 Oct 2002 12:20:38 -0000
*************** get_member_function_from_ptrfunc (instan
*** 2538,2543 ****
--- 2538,2544 ----
tree fntype = TYPE_PTRMEMFUNC_FN_TYPE (TREE_TYPE (function));
tree instance_ptr = *instance_ptrptr;
+ tree instance_save_expr = 0;
if (instance_ptr == error_mark_node)
{
if (TREE_CODE (function) == PTRMEM_CST)
*************** get_member_function_from_ptrfunc (instan
*** 2557,2563 ****
}
if (TREE_SIDE_EFFECTS (instance_ptr))
! instance_ptr = save_expr (instance_ptr);
if (TREE_SIDE_EFFECTS (function))
function = save_expr (function);
--- 2558,2564 ----
}
if (TREE_SIDE_EFFECTS (instance_ptr))
! instance_ptr = instance_save_expr = save_expr (instance_ptr);
if (TREE_SIDE_EFFECTS (function))
function = save_expr (function);
*************** get_member_function_from_ptrfunc (instan
*** 2618,2626 ****
/* Make sure this doesn't get evaluated first inside one of the
branches of the COND_EXPR. */
! if (TREE_CODE (instance_ptr) == SAVE_EXPR)
e1 = build (COMPOUND_EXPR, TREE_TYPE (e1),
! instance_ptr, e1);
function = e1;
}
--- 2619,2627 ----
/* Make sure this doesn't get evaluated first inside one of the
branches of the COND_EXPR. */
! if (instance_save_expr)
e1 = build (COMPOUND_EXPR, TREE_TYPE (e1),
! instance_save_expr, e1);
function = e1;
}
More information about the Gcc-patches
mailing list