]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gcc.target/i386/chkp-stropt-17.c
Daily bump.
[thirdparty/gcc.git] / gcc / testsuite / gcc.target / i386 / chkp-stropt-17.c
CommitLineData
cc8bea0a
MS
1/* { dg-do compile { target { ! x32 } } }
2 { dg-require-effective-target mempcpy }
3 { dg-options "-O2 -Wrestrict -fcheck-pointer-bounds -mmpx" } */
4
5#define USE_GNU
6#include "../../gcc.dg/strlenopt.h"
7
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. */
10char *stpncpy (char *__restrict, const char *__restrict, size_t);
11char *strncpy (char *__restrict, const char *__restrict, size_t);
12char *strncat (char *__restrict, const char *__restrict, size_t);
13
14
15char a[8];
16
17void test_memcpy (void)
18{
19 memcpy (a, a + 1, 3); /* { dg-warning ".memcpy\.chkp. accessing 3 bytes at offsets 0 and 1 overlaps 2 bytes at offset 1" } */
20}
21
22void test_memmove (void)
23{
24 memmove (a, a + 1, 3);
25}
26
27void* test_mempcpy (void)
28{
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" } */
30}
31
32char* test_stpcpy (void)
33{
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" } */
36}
37
38char* test_stpncpy (void)
39{
40 strcpy (a, "0123456");
41
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 *-*-* } } */
44}
45
46void test_strcpy (void)
47{
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" } */
50}
51
52void test_strcat (int n)
53{
816fad6e 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" } */
cc8bea0a
MS
55}
56
57void test_strncat (int n)
58{
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 *-*-* } } */
60}
61
62void test_strncpy (int n)
63{
64 strcpy (a, "0123456");
65
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 *-*-* } } */
68}