From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25389 invoked by alias); 1 Aug 2007 17:09:11 -0000 Received: (qmail 25341 invoked by uid 22791); 1 Aug 2007 17:09:10 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 01 Aug 2007 17:09:05 +0000 Received: from zps18.corp.google.com (zps18.corp.google.com [172.25.146.18]) by smtp-out.google.com with ESMTP id l71H92Af010904 for ; Wed, 1 Aug 2007 18:09:02 +0100 Received: from dhcp-172-29-27-107.tor.corp.google.com (dhcp-172-29-27-107.tor.corp.google.com [172.29.27.107]) by zps18.corp.google.com with ESMTP id l71H8l9A032646 for ; Wed, 1 Aug 2007 10:08:48 -0700 Message-ID: <46B0BE18.40104@google.com> Date: Wed, 01 Aug 2007 17:09:00 -0000 From: Diego Novillo User-Agent: Thunderbird 2.0.0.5 (Macintosh/20070716) MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org Subject: [tuples] Don't ICE if a switch() only has the default label Content-Type: multipart/mixed; boundary="------------080609080701020403030608" X-IsSubscribed: yes 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: 2007-08/txt/msg00060.txt.bz2 This is a multi-part message in MIME format. --------------080609080701020403030608 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 185 This fixes a couple of tests in compile.exp. If a switch only has the default label, the call to sort_case_labels in gimplify_switch_expr() was segfaulting as the vector was empty. --------------080609080701020403030608 Content-Type: text/x-patch; name="20070801-fix-switch-exprs-with-0-labels.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="20070801-fix-switch-exprs-with-0-labels.diff" Content-length: 1948 2007-08-01 Diego Novillo * gimplify.c (gimplify_switch_expr): Do not call sort_case_labels if there are no labels other than 'default'. * gimple.h (gimple_num_ops, gimple_op, gimple_set_op): Use result of GIMPLE_RANGE_CHECK call. Index: gimplify.c =================================================================== --- gimplify.c (revision 127104) +++ gimplify.c (working copy) @@ -1455,7 +1455,9 @@ gimplify_switch_expr (tree *expr_p, gimp default_case = gimple_label_label (new_default); } - sort_case_labels (labels); + if (!VEC_empty (tree, labels)) + sort_case_labels (labels); + gimple_switch = build_gimple_switch_vec (SWITCH_COND (switch_expr), default_case, labels); gimple_add (pre_p, gimple_switch); Index: gimple.h =================================================================== --- gimple.h (revision 127104) +++ gimple.h (working copy) @@ -472,24 +472,24 @@ extern void gimple_range_check_failed (c static inline size_t gimple_num_ops (gimple gs) { - GIMPLE_RANGE_CHECK (gs, GIMPLE_ASSIGN, GIMPLE_RETURN); - return gs->with_ops.num_ops; + gimple g = GIMPLE_RANGE_CHECK (gs, GIMPLE_ASSIGN, GIMPLE_RETURN); + return g->with_ops.num_ops; } static inline tree gimple_op (gimple gs, size_t i) { - GIMPLE_RANGE_CHECK (gs, GIMPLE_ASSIGN, GIMPLE_RETURN); - gcc_assert (i < gs->with_ops.num_ops); - return gs->with_ops.op[i]; + gimple g = GIMPLE_RANGE_CHECK (gs, GIMPLE_ASSIGN, GIMPLE_RETURN); + gcc_assert (i < g->with_ops.num_ops); + return g->with_ops.op[i]; } static inline void gimple_set_op (gimple gs, size_t i, tree op) { - GIMPLE_RANGE_CHECK (gs, GIMPLE_ASSIGN, GIMPLE_RETURN); - gcc_assert (i < gs->with_ops.num_ops); - gs->with_ops.op[i] = op; + gimple g = GIMPLE_RANGE_CHECK (gs, GIMPLE_ASSIGN, GIMPLE_RETURN); + gcc_assert (i < g->with_ops.num_ops); + g->with_ops.op[i] = op; } --------------080609080701020403030608--