Require target lra in gcc.dg/pr108095.c
[official-gcc.git] / gcc / testsuite / gcc.dg / Warray-bounds-40.c
blobc389d96a98b02ba30bf24b6e52d81d4f4f0f2dd0
1 /* PR middle-end/88771 - Misleading -Werror=array-bounds error
2 Verify that the warning issued for calls to "bounded" string
3 functions when -Wstringop-overflow is disabled is -Warray-bounds
4 with the right wording.
5 { dg-do compile }
6 { dg-options "-O2 -Wall -Wno-stringop-overflow -Wno-stringop-overread" } */
8 #define PTRDIFF_MAX __PTRDIFF_MAX__
9 #define SIZE_MAX __SIZE_MAX__
11 typedef __SIZE_TYPE__ size_t;
13 extern void* memcpy (void*, const void*, size_t);
14 extern void* memmove (void*, const void*, size_t);
15 extern void* memset (void*, int, size_t);
17 extern char* stpncpy (char*, const char*, size_t);
19 extern char* strncat (char*, const char*, size_t);
20 extern char* strncpy (char*, const char*, size_t);
22 extern char* strndup (const char*, size_t);
24 extern int strncmp (const char*, const char*, size_t);
25 extern int strncasecmp (const char*, const char*, size_t);
27 extern size_t strnlen (const char*, size_t);
29 extern char *d;
30 extern const char *s;
33 void test_memcpy (void)
35 memcpy (d, s, SIZE_MAX); /* { dg-warning ".memcpy. pointer overflow between offset 0 and size \[0-9\]+ \\\[-Warray-bounds" } */
38 void test_memmove (void)
40 memmove (d, s, SIZE_MAX - 1); /* { dg-warning ".memmove. pointer overflow between offset 0 and size \[0-9\]+ \\\[-Warray-bounds" } */
43 void test_memset (void)
45 memset (d, 0, SIZE_MAX - 2); /* { dg-warning ".memset. pointer overflow between offset 0 and size \[0-9\]+ \\\[-Warray-bounds" } */
49 char* test_stpncpy (void)
51 return stpncpy (d, s, SIZE_MAX - 4); /* { dg-warning ".stpncpy. pointer overflow between offset 0 and size \[0-9\]+ \\\[-Warray-bounds" } */
55 void test_strncat (void)
57 strncat (d, s, SIZE_MAX - 3); /* { dg-warning ".strncat. pointer overflow between offset 0 and size \[0-9\]+ \\\[-Warray-bounds" } */
60 void test_strncpy (void)
62 strncpy (d, s, SIZE_MAX - 4); /* { dg-warning ".strncpy. pointer overflow between offset 0 and size \[0-9\]+ \\\[-Warray-bounds" } */
65 char* test_strndup (void)
67 return strndup (s, SIZE_MAX - 5); /* { dg-warning ".strndup. pointer overflow between offset 0 and size \[0-9\]+ \\\[-Warray-bounds" "bug" { xfail *-*-* } } */
70 size_t test_strnlen (void)
72 return strnlen (s, SIZE_MAX - 6); /* { dg-warning ".strnlen. pointer overflow between offset 0 and size \[0-9\]+ \\\[-Warray-bounds" "bug" { xfail *-*-* } } */