Skip analyzer strndup test on hppa*-*-hpux*
[official-gcc.git] / gcc / testsuite / gcc.dg / Wstringop-overflow-9.c
blob2df84b2bbd91138a3d262897e25e5172b7ac4ec4
1 /* PR middle-end/88771 - Misleading -Werror=array-bounds error
2 Verify that the warning issued for calls to "bounded" string
3 functions is -Wstringop-overflow with the right wording.
4 { dg-do compile }
5 { dg-options "-O2 -Wall" } */
7 #define PTRDIFF_MAX __PTRDIFF_MAX__
8 #define SIZE_MAX __SIZE_MAX__
10 typedef __SIZE_TYPE__ size_t;
12 extern void* memcpy (void*, const void*, size_t);
13 extern void* memmove (void*, const void*, size_t);
14 extern void* memset (void*, int, size_t);
16 extern char* stpncpy (char*, const char*, size_t);
18 extern char* strncat (char*, const char*, size_t);
19 extern char* strncpy (char*, const char*, size_t);
21 extern char* strndup (const char*, size_t);
23 extern int strncmp (const char*, const char*, size_t);
24 extern int strncasecmp (const char*, const char*, size_t);
26 extern size_t strnlen (const char*, size_t);
28 extern char *d;
29 extern const char *s;
32 void test_memcpy (void)
34 memcpy (d, s, SIZE_MAX); /* { dg-warning ".memcpy. specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+ \\\[-Wstringop-overflow=\\\]" } */
37 void test_memmove (void)
39 memmove (d, s, SIZE_MAX - 1); /* { dg-warning ".memmove. specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+ \\\[-Wstringop-overflow=\\\]" } */
42 void test_memset (void)
44 memset (d, 0, SIZE_MAX - 2); /* { dg-warning ".memset. specified \(bound|size\) \[0-9\]+ exceeds maximum object size \[0-9\]+ \\\[-Wstringop-overflow=\\\]" } */
48 char* test_stpncpy (void)
50 return stpncpy (d, s, SIZE_MAX - 4); /* { dg-warning ".stpncpy. specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+ \\\[-Wstringop-overflow=\\\]" } */
54 void test_strncat (void)
56 strncat (d, s, SIZE_MAX - 3); /* { dg-warning ".strncat. specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+ \\\[-Wstringop-overflow=\\\]" } */
59 void test_strncpy (void)
61 strncpy (d, s, SIZE_MAX - 4); /* { dg-warning ".strncpy. specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+ \\\[-Wstringop-overflow=\\\]" } */
64 char* test_strndup (void)
66 return strndup (s, SIZE_MAX - 5); /* { dg-warning ".strndup. specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+ \\\[-Wstringop-overread" } */
69 size_t test_strnlen (void)
71 return strnlen (s, SIZE_MAX - 6); /* { dg-warning ".strnlen. specified bound \[0-9\]+ exceeds maximum object size \[0-9\]+ \\\[-Wstringop-overread" } */