diff options
author | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-08-26 08:51:35 +0000 |
---|---|---|
committer | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-08-26 08:51:35 +0000 |
commit | 314216bfa5b836f0df9af4b9768b82f405c5d333 (patch) | |
tree | 152ffb66aceabfdd630712ed76616a8b76fb2e82 /gcc | |
parent | c8a8ab0fd0affa18cad8ef37b54020d62623d45e (diff) | |
download | gcc-314216bfa5b836f0df9af4b9768b82f405c5d333.tar.gz |
* 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 (build): Set TREE_SIDE_EFFECTS for non-const, non-pure
CALL_EXPRs.
cp:
* 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.
testsuite:
* c++.dg/warn/noeffect3.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@70802 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/builtins.c | 1 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/call.c | 16 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 1 | ||||
-rw-r--r-- | gcc/expr.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/tree.c | 11 |
8 files changed, 35 insertions, 14 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a39a54da3dd..147b68eb3c4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,12 @@ 2003-08-26 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 (build): Set TREE_SIDE_EFFECTS for non-const, non-pure + CALL_EXPRs. + * gcse.c (is_too_expensive): New function. (gcse_main, delete_null_pointer_checks, bypass_jumps): Use it. diff --git a/gcc/builtins.c b/gcc/builtins.c index dc999f722c8..fea2a15d62b 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -6242,7 +6242,6 @@ build_function_call_expr (tree fn, tree arglist) 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); } diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c5823623a43..692937ea36a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2003-08-26 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. + 2003-08-25 Richard Henderson <rth@redhat.com> * cxx-pretty-print.c (pp_cxx_class_name): Remove unused function. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 8440344689a..a74fd63d556 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -303,10 +303,8 @@ build_call (tree function, tree parms) TREE_VALUE (tmp), t); } - function = build_nt (CALL_EXPR, function, parms, NULL_TREE); + function = build (CALL_EXPR, result_type, function, parms); TREE_HAS_CONSTRUCTOR (function) = is_constructor; - TREE_TYPE (function) = result_type; - TREE_SIDE_EFFECTS (function) = 1; TREE_NOTHROW (function) = nothrow; return function; @@ -4918,7 +4916,7 @@ build_new_method_call (tree instance, tree fns, tree args, { call = build_field_call (instance_ptr, fns, args); if (call) - return call; + goto finish; error ("call to non-function `%D'", fns); return error_mark_node; } @@ -5079,13 +5077,11 @@ build_new_method_call (tree instance, tree fns, tree args, 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), + return build_min (CALL_EXPR, TREE_TYPE (call), + build_min_nt (COMPONENT_REF, orig_instance, orig_fns), orig_args); return call; } diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index d5de76aad44..ee80beefad6 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2796,7 +2796,6 @@ simplify_aggr_init_expr (tree *tp) 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 diff --git a/gcc/expr.c b/gcc/expr.c index b7f71c627ba..52cdfee3938 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -2006,7 +2006,6 @@ emit_block_move_via_libcall (rtx dst, rtx src, rtx size) 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); @@ -3120,7 +3119,6 @@ clear_storage_via_libcall (rtx object, rtx size) 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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4da71fc482a..608a27c7d1f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2003-08-26 Nathan Sidwell <nathan@codesourcery.com> + + * c++.dg/warn/noeffect3.C: New test. + 2003-08-25 Janis Johnson <janis187@us.ibm.com> * gcc.dg/compat/vector-1_x.c: Compile with -w. diff --git a/gcc/tree.c b/gcc/tree.c index a12df1cb9f0..df074e85510 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -2378,6 +2378,17 @@ build (enum tree_code code, tree tt, ...) va_end (p); TREE_CONSTANT (t) = constant; + + if (code == CALL_EXPR && !TREE_SIDE_EFFECTS (t)) + { + /* Calls have side-effects, except those to const or + pure functions. */ + tree fn = get_callee_fndecl (t); + + if (!fn || (!DECL_IS_PURE (fn) && !TREE_READONLY (fn))) + TREE_SIDE_EFFECTS (t) = 1; + } + return t; } |