re PR tree-optimization/84224 (ICE in execute, at gimple-ssa-warn-alloca.c:448)
authorAldy Hernandez <aldyh@redhat.com>
Thu, 8 Feb 2018 11:16:25 +0000 (11:16 +0000)
committerAldy Hernandez <aldyh@gcc.gnu.org>
Thu, 8 Feb 2018 11:16:25 +0000 (11:16 +0000)
PR tree-optimization/84224
* gimple-ssa-warn-alloca.c (pass_walloca::execute): Remove assert.
* calls.c (gimple_alloca_call_p): Only return TRUE when we have
non-zero arguments.

From-SVN: r257480

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

index e51ba4f..84bf970 100644 (file)
@@ -1,3 +1,10 @@
+2018-02-08  Aldy Hernandez  <aldyh@redhat.com>
+
+       PR tree-optimization/84224
+       * gimple-ssa-warn-alloca.c (pass_walloca::execute): Remove assert.
+       * calls.c (gimple_alloca_call_p): Only return TRUE when we have
+       non-zero arguments.
+
 2018-02-07  Iain Sandoe  <iain@codesourcery.com>
 
        * config/rs6000/altivec.md (*restore_world): Remove LR use.
index 54fea15..19c95b8 100644 (file)
@@ -730,7 +730,7 @@ gimple_alloca_call_p (const gimple *stmt)
     switch (DECL_FUNCTION_CODE (fndecl))
       {
       CASE_BUILT_IN_ALLOCA:
-        return true;
+       return gimple_call_num_args (stmt) > 0;
       default:
        break;
       }
index 941810a..327c806 100644 (file)
@@ -445,7 +445,6 @@ pass_walloca::execute (function *fun)
 
          if (!gimple_alloca_call_p (stmt))
            continue;
-         gcc_assert (gimple_call_num_args (stmt) >= 1);
 
          const bool is_vla
            = gimple_call_alloca_for_var_p (as_a <gcall *> (stmt));
diff --git a/gcc/testsuite/gcc.dg/Walloca-16.c b/gcc/testsuite/gcc.dg/Walloca-16.c
new file mode 100644 (file)
index 0000000..3ee96a9
--- /dev/null
@@ -0,0 +1,6 @@
+/* PR tree-optimization/84224 */
+/* { dg-do compile } */
+/* { dg-options "-O0 -Walloca" } */
+
+void *alloca ();
+__typeof__(alloca ()) a () { return alloca (); }