summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbje <bje@138bc75d-0d04-0410-961f-82ee72b054a4>2006-10-25 22:58:27 +0000
committerbje <bje@138bc75d-0d04-0410-961f-82ee72b054a4>2006-10-25 22:58:27 +0000
commit032c79284a05b29cf492cae4656891c4e4b2e4f8 (patch)
treeead8385d2a1ae56a3a329acc46673c5f3a8402b0
parent2fa6c4e52c115735adaa63692724ac3d1fba911e (diff)
downloadppe42-gcc-032c79284a05b29cf492cae4656891c4e4b2e4f8.tar.gz
ppe42-gcc-032c79284a05b29cf492cae4656891c4e4b2e4f8.zip
* gcc.c-torture/execute/builtins/strlen.c: Do not use strcpy.
Copy the strings manually, as strcpy may call strlen. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@118045 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/builtins/strlen.c21
2 files changed, 19 insertions, 7 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b90afcc3de2..c9d9df92a91 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2006-10-26 Ben Elliston <bje@au.ibm.com>
+
+ * gcc.c-torture/execute/builtins/strlen.c: Do not use strcpy.
+ Copy the strings manually, as strcpy may call strlen.
+
2006-10-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* gcc.dg/torture/builtin-math-2.c (TESTIT): Use new helper macro.
diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/strlen.c b/gcc/testsuite/gcc.c-torture/execute/builtins/strlen.c
index cf77294713a..3d84c61fd4c 100644
--- a/gcc/testsuite/gcc.c-torture/execute/builtins/strlen.c
+++ b/gcc/testsuite/gcc.c-torture/execute/builtins/strlen.c
@@ -8,7 +8,14 @@
Additional tests written by Roger Sayle, 11/02/2001:
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. */
+ the potentially "pure" strlen calls from being removed by CSE.
+
+ Modifed by Ben Elliston, 2006-10-25:
+ The multiple calls to strcpy that Roger mentions above are
+ problematic on systems where strcpy is implemented using strlen
+ (which this test overrides to call abort). So, rather than use
+ strcpy, we perform the identical operations using array indexing
+ and char assignments. */
extern void abort (void);
extern __SIZE_TYPE__ strlen (const char *);
@@ -33,27 +40,27 @@ main_test(void)
abort ();
ptr = str;
- strcpy (ptr, "nts");
+ ptr[0] = 'n'; ptr[1] = 't'; ptr[2] = 's'; ptr[3] = '\0';
if (strlen (ptr) == 0)
abort ();
- strcpy (ptr, "nts");
+ ptr[0] = 'n'; ptr[1] = 't'; ptr[2] = 's'; ptr[3] = '\0';
if (strlen (ptr) < 1)
abort ();
- strcpy (ptr, "nts");
+ ptr[0] = 'n'; ptr[1] = 't'; ptr[2] = 's'; ptr[3] = '\0';
if (strlen (ptr) <= 0)
abort ();
- strcpy (ptr, "nts");
+ ptr[0] = 'n'; ptr[1] = 't'; ptr[2] = 's'; ptr[3] = '\0';
if (strlen (ptr+3) != 0)
abort ();
- strcpy (ptr, "nts");
+ ptr[0] = 'n'; ptr[1] = 't'; ptr[2] = 's'; ptr[3] = '\0';
if (strlen (ptr+3) > 0)
abort ();
- strcpy (ptr, "nts");
+ ptr[0] = 'n'; ptr[1] = 't'; ptr[2] = 's'; ptr[3] = '\0';
if (strlen (str+3) >= 1)
abort ();
OpenPOWER on IntegriCloud