From patchwork Wed Nov 4 14:35:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Lawrence X-Patchwork-Id: 539981 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 897B7140770 for ; Thu, 5 Nov 2015 01:35:44 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=JizOVH0T; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :content-type:content-transfer-encoding; q=dns; s=default; b=Qkt Mf36ftNGLr/C0t7nkHDVISettELdZAcyWWVva1HK/+gPDE/aRaZ+DKB+xmUjbkig y3Eae0f2BlcrOchs+h0+PCCZY79aWeBG8t5me/37SToc5+kBOgeF/7Ywr9PIEfhX DnaKgoDyHTbmmmVTlHKu0cbm1EO3FPxdAR2JoiY0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :content-type:content-transfer-encoding; s=default; bh=4O6f6EVzw axzeuTNRyiiUBOB4RI=; b=JizOVH0TSQx0CCqFfb88IRbvlI5IcL6JF4npW9DVf FRmGGIRFQVfkJ1WajqnkxHhEqJym/+kDunYI/lLySOqhRfYeF7LJXDRC0RX8NpMm 8SR27cpjSSGJ03sJnwUZhWidXf7CYKsxSVDZSCxfBGKXD9UqOVlwLEbuKd9oSElX nk= Received: (qmail 37297 invoked by alias); 4 Nov 2015 14:35:34 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 37285 invoked by uid 89); 4 Nov 2015 14:35:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (146.101.78.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 04 Nov 2015 14:35:32 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-19-IiG0R4i7SYWhgrlBfefXyw-1; Wed, 04 Nov 2015 14:35:27 +0000 Received: from arm.com ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 4 Nov 2015 14:35:26 +0000 From: Alan Lawrence To: law@redhat.com Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH 3/6] Share code from fold_array_ctor_reference with fold. Date: Wed, 4 Nov 2015 14:35:12 +0000 Message-Id: <1446647712-5560-1-git-send-email-alan.lawrence@arm.com> In-Reply-To: <563827FF.1040309@redhat.com> References: <563827FF.1040309@redhat.com> X-MC-Unique: IiG0R4i7SYWhgrlBfefXyw-1 X-IsSubscribed: yes > s/explicitely/explicitly/ And remove the '*' from the 2nd and 3rd lines > of the comment. > > It looks like get_ctor_element_at_index has numerous formatting > problems. In particular you didn't indent the braces across the board > properly. Also check for tabs vs spaces issues please. Yes, you are quite right, I'm not quite sure how those crept in. (Well, the 'explicitely' I am sure was a copy-paste error but the others!). Apologies... I already committed the offending code as r229605, but here's a patch to clean it up - does it look ok now? Thanks, Alan --- gcc/fold-const.c | 58 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/gcc/fold-const.c b/gcc/fold-const.c index ee9b349..e977b49 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -11855,16 +11855,16 @@ get_array_ctor_element_at_index (tree ctor, offset_int access_index) offset_int low_bound = 0; if (TREE_CODE (TREE_TYPE (ctor)) == ARRAY_TYPE) - { - tree domain_type = TYPE_DOMAIN (TREE_TYPE (ctor)); - if (domain_type && TYPE_MIN_VALUE (domain_type)) { - /* Static constructors for variably sized objects makes no sense. */ - gcc_assert (TREE_CODE (TYPE_MIN_VALUE (domain_type)) == INTEGER_CST); - index_type = TREE_TYPE (TYPE_MIN_VALUE (domain_type)); - low_bound = wi::to_offset (TYPE_MIN_VALUE (domain_type)); + tree domain_type = TYPE_DOMAIN (TREE_TYPE (ctor)); + if (domain_type && TYPE_MIN_VALUE (domain_type)) + { + /* Static constructors for variably sized objects makes no sense. */ + gcc_assert (TREE_CODE (TYPE_MIN_VALUE (domain_type)) == INTEGER_CST); + index_type = TREE_TYPE (TYPE_MIN_VALUE (domain_type)); + low_bound = wi::to_offset (TYPE_MIN_VALUE (domain_type)); + } } - } if (index_type) access_index = wi::ext (access_index, TYPE_PRECISION (index_type), @@ -11880,29 +11880,29 @@ get_array_ctor_element_at_index (tree ctor, offset_int access_index) tree cfield, cval; FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (ctor), cnt, cfield, cval) - { - /* Array constructor might explicitely set index, or specify range - * or leave index NULL meaning that it is next index after previous - * one. */ - if (cfield) { - if (TREE_CODE (cfield) == INTEGER_CST) - max_index = index = wi::to_offset (cfield); + /* Array constructor might explicitly set index, or specify a range, + or leave index NULL meaning that it is next index after previous + one. */ + if (cfield) + { + if (TREE_CODE (cfield) == INTEGER_CST) + max_index = index = wi::to_offset (cfield); + else + { + gcc_assert (TREE_CODE (cfield) == RANGE_EXPR); + index = wi::to_offset (TREE_OPERAND (cfield, 0)); + max_index = wi::to_offset (TREE_OPERAND (cfield, 1)); + } + } else - { - gcc_assert (TREE_CODE (cfield) == RANGE_EXPR); - index = wi::to_offset (TREE_OPERAND (cfield, 0)); - max_index = wi::to_offset (TREE_OPERAND (cfield, 1)); - } - } - else - { - index += 1; - if (index_type) - index = wi::ext (index, TYPE_PRECISION (index_type), - TYPE_SIGN (index_type)); - max_index = index; - } + { + index += 1; + if (index_type) + index = wi::ext (index, TYPE_PRECISION (index_type), + TYPE_SIGN (index_type)); + max_index = index; + } /* Do we have match? */ if (wi::cmpu (access_index, index) >= 0