From 314216bfa5b836f0df9af4b9768b82f405c5d333 Mon Sep 17 00:00:00 2001 From: nathan Date: Tue, 26 Aug 2003 08:51:35 +0000 Subject: * 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 --- gcc/tree.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'gcc/tree.c') 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; } -- cgit v1.2.1