aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr78973-2.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/pr78973-2.c')
-rw-r--r--gcc/testsuite/gcc.dg/pr78973-2.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/pr78973-2.c b/gcc/testsuite/gcc.dg/pr78973-2.c
new file mode 100644
index 0000000..cc3cfc5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr78973-2.c
@@ -0,0 +1,25 @@
+/* PR c/78973 - warning: ‘memcpy’: specified size exceeds maximum object
+ size [-Wstringop-overflow=]
+
+ This is a companion test for the bug above that verifies that the correct
+ range of the int variable is detected.
+
+ { dg-do compile }
+ { dg-require-effective-target int32plus }
+ { dg-options "-O2 -Walloc-size-larger-than=4" } */
+
+void *p;
+
+void f (int n)
+{
+ if (n <= 4)
+ p = __builtin_malloc (n);
+ /* { dg-warning "argument 1 range \\\[\[0-9\]+, \[0-9\]+\\\] exceeds maximum object size 4" "ilp32" { xfail { ! lp64 } } .-1 } */
+}
+
+void g (unsigned n)
+{
+ if (n < 5)
+ n = 5;
+ f (n);
+}