re PR middle-end/78328 (wrong wording for unbounded alloc case in -Walloca-larger...
authorAldy Hernandez <aldyh@redhat.com>
Fri, 2 Dec 2016 12:20:42 +0000 (12:20 +0000)
committerAldy Hernandez <aldyh@gcc.gnu.org>
Fri, 2 Dec 2016 12:20:42 +0000 (12:20 +0000)
PR middle-end/78328
* gimple-ssa-warn-alloca.c (alloca_call_type): Handle
VR_ANTI_RANGE.

From-SVN: r243174

gcc/ChangeLog
gcc/gimple-ssa-warn-alloca.c
gcc/testsuite/gcc.dg/Walloca-12.c [new file with mode: 0644]

index 03387cfcac053bf193d39dfdd4a9bdc1d1082121..afac97374a5620e43cc505f3cd4a28417641f9b1 100644 (file)
@@ -1,3 +1,9 @@
+2016-12-02  Aldy Hernandez  <aldyh@redhat.com>
+
+       PR middle-end/78328
+       * gimple-ssa-warn-alloca.c (alloca_call_type): Handle
+       VR_ANTI_RANGE.
+
 2016-12-02  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
 
        * config/s390/s390.c (s390_save_gprs_to_fprs): Fix RTL sharing
index e75f2fa76fccb555fe30a05ae40a42f158ebfa71..ae379f90c0c6684f3fed1c13976fb30b07be3468 100644 (file)
@@ -339,6 +339,8 @@ alloca_call_type (gimple *stmt, bool is_vla, tree *invalid_casted_type)
                {
                  // Fall through.
                }
+             else if (range_type == VR_ANTI_RANGE)
+               return alloca_type_and_limit (ALLOCA_UNBOUNDED);
              else if (range_type != VR_VARYING)
                return
                  alloca_type_and_limit (ALLOCA_BOUND_MAYBE_LARGE, max);
diff --git a/gcc/testsuite/gcc.dg/Walloca-12.c b/gcc/testsuite/gcc.dg/Walloca-12.c
new file mode 100644 (file)
index 0000000..5d71cda
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-Walloca-larger-than=128 -O2" } */
+
+void f (void*);
+
+void g (unsigned int n)
+{
+  if (n == 7)
+    n = 11;
+  f (__builtin_alloca (n)); /* { dg-warning "unbounded use of 'alloca'" } */
+}