diff options
author | Kaveh R. Ghazi <ghazi@caip.rutgers.edu> | 2000-10-31 18:27:42 +0000 |
---|---|---|
committer | Kaveh Ghazi <ghazi@gcc.gnu.org> | 2000-10-31 18:27:42 +0000 |
commit | bcb38cc180d1f56eab538f76c2a608e6dfd61da9 (patch) | |
tree | 36069d01197f46a9e613f71dc306dcb1c4138213 /gcc/testsuite | |
parent | bc359d3a5d3e8e6a5ad489b9da8740c2cf7bf301 (diff) | |
download | gcc-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/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/stdio-opt-1.c | 28 |
2 files changed, 32 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 33002ac..6097ca2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2000-10-31 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * gcc.c-torture/execute/stdio-opt-1.c: New test. + 2000-10-31 Jakub Jelinek <jakub@redhat.com> * g++.old-deja/g++.other/inline16.C: New test. diff --git a/gcc/testsuite/gcc.c-torture/execute/stdio-opt-1.c b/gcc/testsuite/gcc.c-torture/execute/stdio-opt-1.c new file mode 100644 index 0000000..aeb7302 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/stdio-opt-1.c @@ -0,0 +1,28 @@ +/* Copyright (C) 2000 Free Software Foundation. + + When eliminating NOP calls to builtin fputs, ensure that we still + evaluate the stream argument in case it has side effects. + Written by Kaveh R. Ghazi, 10/30/2000. */ + +#include <stdio.h> + +int main() +{ + FILE *s_array[3] = {stdout, NULL, stdout}, **s_ptr = s_array; + + /* Increment the stream pointer once. */ + fputs ("", *s_ptr++); + + /* Increment the stream pointer a second time. */ + s_ptr++; + + /* If we failed to increment the stream pointer twice, then the + stream passed in here will be NULL and we should crash. */ + fputs ("hello world\n", *s_ptr); + + /* Just in case, If *s_ptr is NULL abort anyway. */ + if (*s_ptr == 0) + abort(); + + return 0; +} |