aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>2000-10-31 18:27:42 +0000
committerKaveh Ghazi <ghazi@gcc.gnu.org>2000-10-31 18:27:42 +0000
commitbcb38cc180d1f56eab538f76c2a608e6dfd61da9 (patch)
tree36069d01197f46a9e613f71dc306dcb1c4138213 /gcc/builtins.c
parentbc359d3a5d3e8e6a5ad489b9da8740c2cf7bf301 (diff)
downloadgcc-bcb38cc180d1f56eab538f76c2a608e6dfd61da9.zip
gcc-bcb38cc180d1f56eab538f76c2a608e6dfd61da9.tar.gz
gcc-bcb38cc180d1f56eab538f76c2a608e6dfd61da9.tar.bz2
builtins.c (expand_builtin_fputs): When deleting NOP calls to builtin fputs...
* builtins.c (expand_builtin_fputs): When deleting NOP calls to builtin fputs, ensure we still evaluate the stream in case it has side-effects. testsuite: * gcc.c-torture/execute/stdio-opt-1.c: New test. From-SVN: r37162
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index e2acada..3304b68 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -2351,7 +2351,13 @@ expand_builtin_fputs (arglist, ignore)
switch (compare_tree_int (len, 1))
{
case -1: /* length is 0, delete the call entirely . */
- return const0_rtx;
+ {
+ /* Evaluate and ignore the argument in case it has
+ side-effects. */
+ expand_expr (TREE_VALUE (TREE_CHAIN (arglist)), const0_rtx,
+ VOIDmode, EXPAND_NORMAL);
+ return const0_rtx;
+ }
case 0: /* length is 1, call fputc. */
{
tree stripped_string = TREE_VALUE (arglist);