summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/string-opt-18.c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2003-05-05 19:31:35 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2003-05-05 19:31:35 +0000
commit647661c6bb7287179a8b6cc17979102c30e3fbb6 (patch)
tree28d5a88a130f796c626606f2d26616bec3b414a9 /gcc/testsuite/gcc.c-torture/execute/string-opt-18.c
parent4b4dcf9c25241741bf464e80a08f2b37acca7b19 (diff)
downloadgcc-647661c6bb7287179a8b6cc17979102c30e3fbb6.tar.gz
* builtins.c (expand_builtin_mempcpy): New function.
(expand_builtin_stpcpy): Optimize stpcpy whose return value is ignored into strcpy no matter what arguments it has. (expand_builtin) <case BUILT_IN_MEMPCPY>: Call expand_builtin_mempcpy. * gcc.c-torture/execute/string-opt-18.c (main): Add 3 new tests. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@66498 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.c-torture/execute/string-opt-18.c')
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/string-opt-18.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/execute/string-opt-18.c b/gcc/testsuite/gcc.c-torture/execute/string-opt-18.c
index 0ba2be6e628..dfa5c169e2d 100644
--- a/gcc/testsuite/gcc.c-torture/execute/string-opt-18.c
+++ b/gcc/testsuite/gcc.c-torture/execute/string-opt-18.c
@@ -15,6 +15,9 @@ extern int memcmp (const void *, const void *, size_t);
const char s1[] = "123";
char p[32] = "";
+char *s2 = "defg";
+char *s3 = "FGH";
+size_t l1 = 1;
int main()
{
@@ -60,6 +63,17 @@ int main()
if (__builtin_mempcpy (p, "ABCDE", 6) != p + 6 || memcmp (p, "ABCDE", 6))
abort ();
+ /* If the result of stpcpy/mempcpy is ignored, gcc should use
+ strcpy/memcpy. */
+ stpcpy (p + 3, s2);
+ if (memcmp (p, "ABCdefg", 8))
+ abort ();
+ mempcpy (p + 5, s3, 1);
+ if (memcmp (p, "ABCdeFg", 8))
+ abort ();
+ mempcpy (p + 6, s3 + 1, l1);
+ if (memcmp (p, "ABCdeFG", 8))
+ abort ();
return 0;
}