aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/Wstringop-overflow-13.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/Wstringop-overflow-13.c')
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overflow-13.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-13.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-13.c
new file mode 100644
index 0000000..bd51315
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-13.c
@@ -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]" } */