This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR49615


This fixes an oversight in split_bbs_on_noreturn_calls.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied everywhere.

Richard.

2011-07-04  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/49615
	* tree-cfgcleanup.c (split_bbs_on_noreturn_calls): Fix
	basic-block index check.

	* g++.dg/torture/pr49615.C: New testcase.

Index: gcc/tree-cfgcleanup.c
===================================================================
*** gcc/tree-cfgcleanup.c	(revision 175752)
--- gcc/tree-cfgcleanup.c	(working copy)
*************** split_bbs_on_noreturn_calls (void)
*** 599,605 ****
  	   BB is present in the cfg.  */
  	if (bb == NULL
  	    || bb->index < NUM_FIXED_BLOCKS
! 	    || bb->index >= n_basic_blocks
  	    || BASIC_BLOCK (bb->index) != bb
  	    || !gimple_call_noreturn_p (stmt))
  	  continue;
--- 599,605 ----
  	   BB is present in the cfg.  */
  	if (bb == NULL
  	    || bb->index < NUM_FIXED_BLOCKS
! 	    || bb->index >= last_basic_block
  	    || BASIC_BLOCK (bb->index) != bb
  	    || !gimple_call_noreturn_p (stmt))
  	  continue;
Index: gcc/testsuite/g++.dg/torture/pr49615.C
===================================================================
*** gcc/testsuite/g++.dg/torture/pr49615.C	(revision 0)
--- gcc/testsuite/g++.dg/torture/pr49615.C	(revision 0)
***************
*** 0 ****
--- 1,29 ----
+ /* { dg-do compile } */
+ /* { dg-options "-g" } */
+ 
+ template <class T>
+ static inline bool Dispatch (T* obj, void (T::*func) ())
+ {
+   (obj->*func) ();
+ }
+ class C
+ {
+   bool f (int);
+   void g ();
+ };
+ bool C::f (int n)
+ {
+   bool b;
+   switch (n)
+     {
+       case 0:
+ 	  b = Dispatch (this, &C::g);
+       case 1:
+ 	  b = Dispatch (this, &C::g);
+     }
+ }
+ void C::g ()
+ {
+   for (;;) { }
+ }
+ 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]