Dead
[official-gcc.git] / gomp-20050608-branch / gcc / testsuite / gcc.c-torture / execute / builtins / strpcpy-2.c
blobeb275c422c24d0a222bbfb2030b60e8867d49a30
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;
13 long buf1[64];
14 char *buf2 = (char *) (buf1 + 32);
15 long buf5[20];
16 char buf7[20];
18 void
19 __attribute__((noinline))
20 test (long *buf3, char *buf4, char *buf6, int n)
22 int i = 4;
24 if (stpcpy ((char *) buf3, "abcdefghijklmnop") != (char *) buf1 + 16
25 || memcmp (buf1, "abcdefghijklmnop", 17))
26 abort ();
28 if (__builtin_stpcpy ((char *) buf3, "ABCDEFG") != (char *) buf1 + 7
29 || memcmp (buf1, "ABCDEFG\0ijklmnop", 17))
30 abort ();
32 if (stpcpy ((char *) buf3 + i++, "x") != (char *) buf1 + 5
33 || memcmp (buf1, "ABCDx\0G\0ijklmnop", 17))
34 abort ();
37 void
38 main_test (void)
40 /* All these tests are allowed to call mempcpy/stpcpy. */
41 inside_main = 0;
42 __builtin_memcpy (buf5, "RSTUVWXYZ0123456789", 20);
43 __builtin_memcpy (buf7, "RSTUVWXYZ0123456789", 20);
44 test (buf1, buf2, "rstuvwxyz", 0);