Patchwork [4.7] Fix PR56501

login
register
mail settings
Submitter Richard Guenther
Date April 3, 2013, 10:12 a.m.
Message ID <alpine.LNX.2.00.1304031212130.21094@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/233341/
State New
Headers show

Comments

Richard Guenther - April 3, 2013, 10:12 a.m.
The following obvious fix fixes the ICE in PR56501.

Boostrap / regtest pending on x86_64-unknown-linux-gnu.

Richard.

2013-04-03  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/56501
	* tree-switch-conversion.c (check_process_case): Properly
	handle !single_succ_p case.

	* gcc.dg/torture/pr56501.c: New testcase.

Patch

Index: gcc/tree-switch-conversion.c
===================================================================
--- gcc/tree-switch-conversion.c	(revision 197348)
+++ gcc/tree-switch-conversion.c	(working copy)
@@ -283,7 +283,12 @@  check_process_case (tree cs)
 	  return false;
 	}
 
-      e = single_succ_edge (label_bb);
+      if (!single_succ_p (label_bb))
+	{
+	  info.reason
+	    = "  Bad case - a non-final BB without a single successor\n";
+	  return false;
+	}
       following_bb = single_succ (label_bb);
     }
 
Index: gcc/testsuite/gcc.dg/torture/pr56501.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr56501.c	(revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr56501.c	(working copy)
@@ -0,0 +1,27 @@ 
+/* { dg-do compile } */
+/* { dg-options "-w" } */
+
+int a;
+void try_help () __attribute__ ((__noreturn__));
+void try_help ()
+{
+}
+
+int main ()
+{
+  switch (a)
+    {
+      case '1':
+      case '2':
+      case '3':
+      case '4':
+      case '5':
+      case '6':
+      case '7':
+      case '8':
+      case '9':
+	  break;
+      default:
+	  try_help ();
+    }
+}