Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / gcc.c-torture / execute / builtins / pr23484-chk.c
blob58d4db4b21b13ebb2e1d0c05b920c934c72b2263
1 /* PR middle-end/23484 */
3 extern void abort (void);
4 typedef __SIZE_TYPE__ size_t;
5 extern size_t strlen (const char *);
6 extern void *memcpy (void *, const void *, size_t);
7 extern void *mempcpy (void *, const void *, size_t);
8 extern void *memmove (void *, const void *, size_t);
9 extern int snprintf (char *, size_t, const char *, ...);
10 extern int memcmp (const void *, const void *, size_t);
12 #include "chk.h"
14 static char data[8] = "ABCDEFG";
16 int l1;
18 void
19 __attribute__((noinline))
20 test1 (void)
22 char buf[8];
24 /* All the checking calls in this routine have a maximum length, so
25 object size checking should be done at compile time if optimizing. */
26 chk_calls = 0;
28 memset (buf, 'I', sizeof (buf));
29 if (memcpy (buf, data, l1 ? sizeof (buf) : 4) != buf
30 || memcmp (buf, "ABCDIIII", 8))
31 abort ();
33 memset (buf, 'J', sizeof (buf));
34 if (mempcpy (buf, data, l1 ? sizeof (buf) : 4) != buf + 4
35 || memcmp (buf, "ABCDJJJJ", 8))
36 abort ();
38 memset (buf, 'K', sizeof (buf));
39 if (memmove (buf, data, l1 ? sizeof (buf) : 4) != buf
40 || memcmp (buf, "ABCDKKKK", 8))
41 abort ();
43 memset (buf, 'L', sizeof (buf));
44 if (snprintf (buf, l1 ? sizeof (buf) : 4, "%d", l1 + 65536) != 5
45 || memcmp (buf, "655\0LLLL", 8))
46 abort ();
48 if (chk_calls)
49 abort ();
52 void
53 main_test (void)
55 #ifndef __OPTIMIZE__
56 /* Object size checking is only intended for -O[s123]. */
57 return;
58 #endif
59 __asm ("" : "=r" (l1) : "0" (l1));
60 test1 ();