re PR middle-end/79809 (ICE in alloca_call_type, at gimple-ssa-warn-alloca.c:282)
authorMarek Polacek <polacek@redhat.com>
Tue, 7 Mar 2017 17:30:53 +0000 (17:30 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Tue, 7 Mar 2017 17:30:53 +0000 (17:30 +0000)
PR middle-end/79809
* gimple-ssa-warn-alloca.c (pass_walloca::gate): Use HOST_WIDE_INT.
(alloca_call_type): Likewise.

* g++.dg/Walloca1.C: New test.

From-SVN: r245955

gcc/ChangeLog
gcc/gimple-ssa-warn-alloca.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/Walloca1.C [new file with mode: 0644]

index 39ca488..250bd8c 100644 (file)
@@ -1,3 +1,9 @@
+2017-03-07  Marek Polacek  <polacek@redhat.com>
+
+       PR middle-end/79809
+       * gimple-ssa-warn-alloca.c (pass_walloca::gate): Use HOST_WIDE_INT.
+       (alloca_call_type): Likewise.
+
 2017-03-07  Martin Liska  <mliska@suse.cz>
 
        * gcov.c (process_args): Put comment to correct location.
index d553a34..dd41775 100644 (file)
@@ -78,7 +78,8 @@ pass_walloca::gate (function *fun ATTRIBUTE_UNUSED)
   if (first_time_p)
     return warn_alloca != 0;
 
-  return warn_alloca_limit > 0 || warn_vla_limit > 0;
+  return ((unsigned HOST_WIDE_INT) warn_alloca_limit > 0
+         || (unsigned HOST_WIDE_INT) warn_vla_limit > 0);
 }
 
 // Possible problematic uses of alloca.
@@ -278,8 +279,8 @@ alloca_call_type (gimple *stmt, bool is_vla, tree *invalid_casted_type)
   wide_int min, max;
   struct alloca_type_and_limit ret = alloca_type_and_limit (ALLOCA_UNBOUNDED);
 
-  gcc_assert (!is_vla || warn_vla_limit > 0);
-  gcc_assert (is_vla || warn_alloca_limit > 0);
+  gcc_assert (!is_vla || (unsigned HOST_WIDE_INT) warn_vla_limit > 0);
+  gcc_assert (is_vla || (unsigned HOST_WIDE_INT) warn_alloca_limit > 0);
 
   // Adjust warn_alloca_max_size for VLAs, by taking the underlying
   // type into account.
index 932e792..ce63eb0 100644 (file)
@@ -1,3 +1,8 @@
+2017-03-07  Marek Polacek  <polacek@redhat.com>
+
+       PR middle-end/79809
+       * g++.dg/Walloca1.C: New test.
+
 2017-03-07  Martin Liska  <mliska@suse.cz>
 
        PR middle-end/68270
diff --git a/gcc/testsuite/g++.dg/Walloca1.C b/gcc/testsuite/g++.dg/Walloca1.C
new file mode 100644 (file)
index 0000000..23b97e8
--- /dev/null
@@ -0,0 +1,6 @@
+/* PR middle-end/79809 */
+/* { dg-do compile } */
+/* { dg-options "-Walloca-larger-than=4207115063 -Wvla-larger-than=1233877270 -O2" } */
+
+int a;
+char *b = static_cast<char *>(__builtin_alloca (a)); // { dg-warning "argument to .alloca. may be too large" }