1 /* Copyright (C) 2003 Free Software Foundation.
3 Ensure that builtin stpcpy performs correctly.
5 Written by Jakub Jelinek, 21/05/2003. */
7 extern void abort (void);
8 typedef __SIZE_TYPE__
size_t;
9 extern int memcmp (const void *, const void *, size_t);
10 extern char *stpcpy (char *, const char *);
11 extern int inside_main
;
14 char *buf2
= (char *) (buf1
+ 32);
19 __attribute__((noinline
))
20 test (long *buf3
, char *buf4
, char *buf6
, int n
)
24 if (stpcpy ((char *) buf3
, "abcdefghijklmnop") != (char *) buf1
+ 16
25 || memcmp (buf1
, "abcdefghijklmnop", 17))
28 if (__builtin_stpcpy ((char *) buf3
, "ABCDEFG") != (char *) buf1
+ 7
29 || memcmp (buf1
, "ABCDEFG\0ijklmnop", 17))
32 if (stpcpy ((char *) buf3
+ i
++, "x") != (char *) buf1
+ 5
33 || memcmp (buf1
, "ABCDx\0G\0ijklmnop", 17))
40 /* All these tests are allowed to call mempcpy/stpcpy. */
42 __builtin_memcpy (buf5
, "RSTUVWXYZ0123456789", 20);
43 __builtin_memcpy (buf7
, "RSTUVWXYZ0123456789", 20);
44 test (buf1
, buf2
, "rstuvwxyz", 0);