diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-11-14 08:19:59 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-11-14 08:19:59 +0000 |
commit | 886a914d490ef02b247e1fe6408620443d8d5fc5 (patch) | |
tree | 5537fc814587dbdb7ede402625d46e737bc763c9 /gcc/tree.c | |
parent | 4e2086f339c6f1dc8e53c13de9c4052bb983b6dc (diff) | |
download | gcc-886a914d490ef02b247e1fe6408620443d8d5fc5.tar.gz |
PR middle-end/12526
* tree.c (build): A CALL_EXPR has side-effects if its arguments do.
* calls.c (call_expr_flags): New fn.
* tree.h: Declare it.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@73589 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/gcc/tree.c b/gcc/tree.c index 66e0afd7351..8466990ad5d 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -2294,6 +2294,7 @@ build (enum tree_code code, tree tt, ...) int fro; int constant; va_list p; + tree node; va_start (p, tt); @@ -2380,10 +2381,17 @@ build (enum tree_code code, tree tt, ...) { /* 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))) + i = call_expr_flags (t); + if (!(i & (ECF_CONST | ECF_PURE))) TREE_SIDE_EFFECTS (t) = 1; + + /* And even those have side-effects if their arguments do. */ + else for (node = TREE_OPERAND (t, 1); node; node = TREE_CHAIN (node)) + if (TREE_SIDE_EFFECTS (TREE_VALUE (node))) + { + TREE_SIDE_EFFECTS (t) = 1; + break; + } } return t; |