diff options
author | Roger Sayle <roger@eyesopen.com> | 2001-11-14 23:37:31 +0000 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2001-11-14 15:37:31 -0800 |
commit | c1a7b241d1701d9914ee0eb394d6c84d8d163e9d (patch) | |
tree | e0da2d93fbeac604d3d2642412cc91cddf5e0ee5 | |
parent | d59b3b679c686f86430a4a6fc5f24058ce2e5174 (diff) | |
download | gcc-c1a7b241d1701d9914ee0eb394d6c84d8d163e9d.zip gcc-c1a7b241d1701d9914ee0eb394d6c84d8d163e9d.tar.gz gcc-c1a7b241d1701d9914ee0eb394d6c84d8d163e9d.tar.bz2 |
* gcc.c-torture/execute/string-opt-13.c: New testcase.
From-SVN: r47030
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/string-opt-13.c | 58 |
2 files changed, 62 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ee057ac..f711835 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2001-11-14 Roger Sayle <roger@eyesopen.com> + + * gcc.c-torture/execute/string-opt-13.c: New testcase. + 2001-11-14 Richard Sandiford <rsandifo@redhat.com> * g++.dg/init/array2.C: New test. diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-13.c b/gcc/testsuite/gcc.c-torture/execute/string-opt-13.c new file mode 100644 index 0000000..3060f91 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/string-opt-13.c @@ -0,0 +1,58 @@ +/* Copyright (C) 2001 Free Software Foundation. + + Ensure all builtin strlen comparisons against zero are optimized + and perform correctly. The multiple calls to strcpy are to prevent + the potentially "pure" strlen calls from being removed by CSE. + + Written by Roger Sayle, 11/02/2001. */ + +extern void abort (void); +typedef __SIZE_TYPE__ size_t; +extern size_t strlen (const char *); +extern char *strcpy (char *, const char *); + +int +main () +{ + char str[8]; + char *ptr; + + ptr = str; + strcpy (ptr, "nts"); + if (strlen (ptr) == 0) + abort (); + + strcpy (ptr, "nts"); + if (strlen (ptr) < 1) + abort (); + + strcpy (ptr, "nts"); + if (strlen (ptr) <= 0) + abort (); + + strcpy (ptr, "nts"); + if (strlen (ptr+3) != 0) + abort (); + + strcpy (ptr, "nts"); + if (strlen (ptr+3) > 0) + abort (); + + strcpy (ptr, "nts"); + if (strlen (str+3) >= 1) + abort (); + + return 0; +} + +#ifdef __OPTIMIZE__ +/* When optimizing, all the above cases should be transformed into + something else. So any remaining calls to the original function + should abort. */ +static size_t +strlen (const char *s) +{ + abort (); +} +#endif + |