Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / chkp-stropt-17.c
blobfaf304c33039961c55f8b6b3271a3e4ececbb6bb
1 /* { dg-do compile { target { ! x32 } } }
2 { dg-require-effective-target mempcpy }
3 { dg-options "-O2 -Wrestrict -fcheck-pointer-bounds -mmpx" } */
5 #define USE_GNU
6 #include "../../gcc.dg/strlenopt.h"
8 /* There is no BUILT_IN_ST{P,R}NCPY_CHKP or BUILT_IN_STRNCAT_CHKP
9 so the test for them below are XFAIL. */
10 char *stpncpy (char *__restrict, const char *__restrict, size_t);
11 char *strncpy (char *__restrict, const char *__restrict, size_t);
12 char *strncat (char *__restrict, const char *__restrict, size_t);
15 char a[8];
17 void test_memcpy (void)
19 memcpy (a, a + 1, 3); /* { dg-warning ".memcpy\.chkp. accessing 3 bytes at offsets 0 and 1 overlaps 2 bytes at offset 1" } */
22 void test_memmove (void)
24 memmove (a, a + 1, 3);
27 void* test_mempcpy (void)
29 return mempcpy (a, a + 1, 3); /* { dg-warning ".mempcpy\.chkp. accessing 3 bytes at offsets 0 and 1 overlaps 2 bytes at offset 1" } */
32 char* test_stpcpy (void)
34 strcpy (a, "0123456");
35 return stpcpy (a, a + 2); /* { dg-warning ".stpcpy\.chkp. accessing 6 bytes at offsets 0 and 2 overlaps 4 bytes at offset 2" } */
38 char* test_stpncpy (void)
40 strcpy (a, "0123456");
42 /* There is no BUILT_IN_STPNCPY_CHKP so this isn't handled. */
43 return stpncpy (a, a + 2, sizeof a); /* { dg-warning ".stpcpy\.chkp. accessing 7 bytes at offsets 0 and 2 overlaps 4 bytes at offset 2" "bug 82652" { xfail *-*-* } } */
46 void test_strcpy (void)
48 strcpy (a, "0123456");
49 strcpy (a, a + 1); /* { dg-warning ".strcpy\.chkp. accessing 7 bytes at offsets 0 and 1 overlaps 6 bytes at offset 1" } */
52 void test_strcat (int n)
54 strcat (a, a + 3); /* { dg-warning ".strcat\.chkp. accessing 4 or more bytes at offsets 0 and 3 may overlap 1 byte at offset 3" } */
57 void test_strncat (int n)
59 strncat (a, a + 3, sizeof a); /* { dg-warning ".strncat\.chkp. accessing 0 or more bytes at offsets 0 and 3 may overlap 1 byte" "bug 82652" { xfail *-*-* } } */
62 void test_strncpy (int n)
64 strcpy (a, "0123456");
66 /* There is no BUILT_IN_STRNCPY_CHKP so this isn't handled. */
67 strncpy (a, a + 2, sizeof a); /* { dg-warning ".strncpy\.chkp. accessing 7 bytes at offsets 0 and 2 overlaps 5 bytes at offset 2" "bug 82652" { xfail *-*-* } } */