This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH]: CALL_EXPR should set TREE_SIDE_EFFECTS
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org, Mark Mitchell <mitchell at codesourcery dot com>
- Date: Fri, 22 Aug 2003 09:37:45 +0100
- Subject: [PATCH]: CALL_EXPR should set TREE_SIDE_EFFECTS
- Organization: Codesourcery LLC
In tracking down the regressions I'v caused in C++ wrt no-effect
expressions, I discovered that building a CALL_EXPR does not automatically
set TREE_SIDE_EFFECTS. Both C & C++ frontends set it explicitly immediately
afterwards (but C++ forgets a few places).
No test case on this, as it is not a full fix for the C++ problems.
booted & tested on i686-pc-linux-gnu, ok?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
The voices in my head said this was stupid too
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
2003-08-21 Nathan Sidwell <nathan@codesourcery.com>
* builtins.c (build_function_call_expr): Don't set
TREE_SIDE_EFFECTS here.
* expr.c (emit_block_move_via_libcall): Likewise.
(clear_storage_via_libcall): Likewise.
* tree.c (make_node): Set TREE_SIDE_EFFECTS for a CALL_EXPR.
2003-08-21 Nathan Sidwell <nathan@codesourcery.com>
* call.c (build_call): Don't set TREE_SIDE_EFFECTS here.
(build_new_method_call): Add goto finish.
* semantics.c (simplify_aggr_init_exprs_r): Don't set
TREE_SIDE_EFFECTS on a call.
Index: builtins.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/builtins.c,v
retrieving revision 1.239
diff -c -3 -p -r1.239 builtins.c
*** builtins.c 19 Aug 2003 23:21:51 -0000 1.239
--- builtins.c 21 Aug 2003 17:31:04 -0000
*************** build_function_call_expr (tree fn, tree
*** 6198,6204 ****
call_expr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (fn)), fn);
call_expr = build (CALL_EXPR, TREE_TYPE (TREE_TYPE (fn)),
call_expr, arglist);
- TREE_SIDE_EFFECTS (call_expr) = 1;
return fold (call_expr);
}
--- 6198,6203 ----
Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expr.c,v
retrieving revision 1.577
diff -c -3 -p -r1.577 expr.c
*** expr.c 19 Aug 2003 23:21:57 -0000 1.577
--- expr.c 21 Aug 2003 17:31:27 -0000
*************** emit_block_move_via_libcall (rtx dst, rt
*** 1997,2003 ****
call_expr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (fn)), fn);
call_expr = build (CALL_EXPR, TREE_TYPE (TREE_TYPE (fn)),
call_expr, arg_list, NULL_TREE);
- TREE_SIDE_EFFECTS (call_expr) = 1;
retval = expand_expr (call_expr, NULL_RTX, VOIDmode, 0);
--- 1997,2002 ----
*************** clear_storage_via_libcall (rtx object, r
*** 3111,3117 ****
call_expr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (fn)), fn);
call_expr = build (CALL_EXPR, TREE_TYPE (TREE_TYPE (fn)),
call_expr, arg_list, NULL_TREE);
- TREE_SIDE_EFFECTS (call_expr) = 1;
retval = expand_expr (call_expr, NULL_RTX, VOIDmode, 0);
--- 3110,3115 ----
Index: tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.c,v
retrieving revision 1.323
diff -c -3 -p -r1.323 tree.c
*** tree.c 19 Aug 2003 23:22:00 -0000 1.323
--- tree.c 21 Aug 2003 17:31:37 -0000
*************** make_node (enum tree_code code)
*** 323,328 ****
--- 323,329 ----
case PREINCREMENT_EXPR:
case POSTDECREMENT_EXPR:
case POSTINCREMENT_EXPR:
+ case CALL_EXPR:
/* All of these have side-effects, no matter what their
operands are. */
TREE_SIDE_EFFECTS (t) = 1;
Index: cp/call.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/call.c,v
retrieving revision 1.421
diff -c -3 -p -r1.421 call.c
*** cp/call.c 12 Aug 2003 22:26:20 -0000 1.421
--- cp/call.c 21 Aug 2003 17:31:59 -0000
*************** build_call (tree function, tree parms)
*** 306,312 ****
function = build_nt (CALL_EXPR, function, parms, NULL_TREE);
TREE_HAS_CONSTRUCTOR (function) = is_constructor;
TREE_TYPE (function) = result_type;
- TREE_SIDE_EFFECTS (function) = 1;
TREE_NOTHROW (function) = nothrow;
return function;
--- 306,311 ----
*************** build_new_method_call (tree instance, tr
*** 4912,4918 ****
{
call = build_field_call (instance_ptr, fns, args);
if (call)
! return call;
error ("call to non-function `%D'", fns);
return error_mark_node;
}
--- 4911,4917 ----
{
call = build_field_call (instance_ptr, fns, args);
if (call)
! goto finish;
error ("call to non-function `%D'", fns);
return error_mark_node;
}
*************** build_new_method_call (tree instance, tr
*** 5073,5085 ****
if (!is_dummy_object (instance_ptr) && TREE_SIDE_EFFECTS (instance))
call = build (COMPOUND_EXPR, TREE_TYPE (call), instance, call);
}
!
if (processing_template_decl && call != error_mark_node)
! return build_min (CALL_EXPR,
! TREE_TYPE (call),
! build_min_nt (COMPONENT_REF,
! orig_instance,
! orig_fns),
orig_args);
return call;
}
--- 5072,5082 ----
if (!is_dummy_object (instance_ptr) && TREE_SIDE_EFFECTS (instance))
call = build (COMPOUND_EXPR, TREE_TYPE (call), instance, call);
}
! finish:;
!
if (processing_template_decl && call != error_mark_node)
! return build_min (CALL_EXPR, TREE_TYPE (call),
! build_min_nt (COMPONENT_REF, orig_instance, orig_fns),
orig_args);
return call;
}
Index: cp/semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/semantics.c,v
retrieving revision 1.349
diff -c -3 -p -r1.349 semantics.c
*** cp/semantics.c 20 Aug 2003 18:00:08 -0000 1.349
--- cp/semantics.c 21 Aug 2003 17:32:17 -0000
*************** simplify_aggr_init_exprs_r (tree* tp,
*** 2776,2782 ****
call_expr = build (CALL_EXPR,
TREE_TYPE (TREE_TYPE (TREE_TYPE (fn))),
fn, args, NULL_TREE);
- TREE_SIDE_EFFECTS (call_expr) = 1;
if (style == arg)
/* Tell the backend that we've added our return slot to the argument
--- 2776,2781 ----