re PR tree-optimization/84740 (ICE in build_constructors, at tree-switch-conversion...
authorJakub Jelinek <jakub@redhat.com>
Thu, 8 Mar 2018 07:29:42 +0000 (08:29 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 8 Mar 2018 07:29:42 +0000 (08:29 +0100)
PR tree-optimization/84740
* tree-switch-conversion.c (process_switch): Call build_constructors
only if info.phi_count is non-zero.

* gcc.dg/torture/pr84740.c: New test.

From-SVN: r258354

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr84740.c [new file with mode: 0644]
gcc/tree-switch-conversion.c

index c96e895..39587da 100644 (file)
@@ -1,5 +1,9 @@
 2018-03-08  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/84740
+       * tree-switch-conversion.c (process_switch): Call build_constructors
+       only if info.phi_count is non-zero.
+
        PR tree-optimization/84739
        * tree-tailcall.c (find_tail_calls): Check call arguments against
        DECL_ARGUMENTS (current_function_decl) rather than
index 3f0ac96..a42a376 100644 (file)
@@ -1,5 +1,8 @@
 2018-03-08  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/84740
+       * gcc.dg/torture/pr84740.c: New test.
+
        PR tree-optimization/84739
        * gcc.dg/pr84739.c: New test.
 
diff --git a/gcc/testsuite/gcc.dg/torture/pr84740.c b/gcc/testsuite/gcc.dg/torture/pr84740.c
new file mode 100644 (file)
index 0000000..8fcc028
--- /dev/null
@@ -0,0 +1,24 @@
+/* PR tree-optimization/84740 */
+
+void
+frobulate_for_gcc (unsigned int v)
+{
+  const char *s;
+  switch (v)
+    {
+    case 0:
+      s = "foo";
+      break;
+    case 1:
+      s = "bar";
+      break;
+    case 2:
+      s = "spam";
+      break;
+    default:
+      s = (const char *) 0;
+      break;
+    }
+  if (!s)
+    __builtin_printf ("%s\n", s);
+}
index c253890..2da7068 100644 (file)
@@ -1563,7 +1563,8 @@ process_switch (gswitch *swtch)
   gather_default_values (info.default_case_nonstandard
                         ? gimple_switch_label (swtch, 1)
                         : gimple_switch_default_label (swtch), &info);
-  build_constructors (swtch, &info);
+  if (info.phi_count)
+    build_constructors (swtch, &info);
 
   build_arrays (swtch, &info); /* Build the static arrays and assignments.   */
   gen_inbound_check (swtch, &info);    /* Build the bounds check.  */