From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9833 invoked by alias); 4 Jul 2011 12:02:34 -0000 Received: (qmail 9822 invoked by uid 22791); 4 Jul 2011 12:02:34 -0000 X-SWARE-Spam-Status: No, hits=-3.3 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 04 Jul 2011 12:02:18 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id BEF738765C for ; Mon, 4 Jul 2011 14:02:17 +0200 (CEST) Date: Mon, 04 Jul 2011 12:02:00 -0000 From: Richard Guenther To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR49615 Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-07/txt/msg00176.txt.bz2 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 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 + 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 (;;) { } + } +