diff gcc/testsuite/gcc.dg/Wstringop-overflow-13.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-13.c	Thu Feb 13 11:34:05 2020 +0900
@@ -0,0 +1,40 @@
+/* PR middle-end/89957 - ICE calling strnlen with an int128_t bound
+   in a known range
+   PR middle-end/89911 - ICE on a call with no arguments to strnlen
+   declared with no prototype
+   { dg-do compile }
+   { dg-options "-O2 -Wall" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+extern size_t strnlen ();
+
+size_t f0 (void)
+{
+  return strnlen ();          /* { dg-warning "too few arguments to built-in function 'strnlen'" } */
+}
+
+size_t f1 (const char *s)
+{
+  return strnlen (s);         /* { dg-warning "too few arguments to built-in function 'strnlen'" } */
+}
+
+size_t f2 (const char *s)
+{
+  return strnlen (s, s);      /* { dg-warning "\\\[-Wint-conversion]" } */
+}
+
+#if __SIZEOF_INT128__ == 16
+
+size_t fi128 (const char *s, __int128_t n)
+{
+ if (n < 0)
+   n = 0;
+
+ /* PR middle-end/89957 */
+ return strnlen (s, n);       /* { dg-warning "\\\[-Wbuiltin-declaration-mismatch]" "int128" { target int128 } } */
+}
+
+#endif
+
+/* { dg-prune-output "\\\[-Wint-conversion]" } */