From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id 208123858C2C; Fri, 25 Mar 2022 10:13:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 208123858C2C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.90,209,1643702400"; d="scan'208";a="73435347" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa3.mentor.iphmx.com with ESMTP; 25 Mar 2022 02:13:29 -0800 IronPort-SDR: aYwX1O/P1r5y3f1gnXbnq5URBAChIGsh0bFGfKi49OGxKxkQAR20UVnUAObhIMPLFQT0MPKs1n BdKyt7L8hblFy5Q7Kp0RWE9kSvmSfiku9N9lOaOYoTE8CvkSUT6hWhIR/PLFcM+PjRn9hzPdoP 6YkdT1LJvsKKLcn3hdAv6HG3sy72ZZtrHtXMzQYwfk8PaNwvMT6dcdPGkzLMMfHwk2h1/zDQyl L8pH6503TcCBUQTrrJCd0HcPYCxJw0mOk0XQsjr5X8+MgA+QsdJrKFLy8ksRj7/j9B52Nu7BqA jkE= Message-ID: Date: Fri, 25 Mar 2022 11:13:23 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH] fortran: Fix up initializers of param(0) PARAMETERs [PR103691] Content-Language: en-US To: Jakub Jelinek , CC: References: From: Tobias Burnus In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: quoted-printable X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-02.mgc.mentorg.com (139.181.222.2) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Mar 2022 10:13:31 -0000 On 25.03.22 09:57, Jakub Jelinek via Fortran wrote: > On the gfortran.dg/pr103691.f90 testcase the Fortran ICE emits > static real(kind=3D4) a[0] =3D {[0 ... -1]=3D2.0e+0}; > That is an invalid RANGE_EXPR where the maximum is smaller than the minim= um. > > The following patch fixes that. If TYPE_MAX_VALUE is smaller than > TYPE_MIN_VALUE, the array is empty and so doesn't need any initializer, > if the two are equal, we don't need to bother with a RANGE_EXPR and > can just use that INTEGER_CST as the index and finally for the 2+ values > in the range it uses a RANGE_EXPR as before. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? LGTM =E2=80=93 thanks for taking care of Fortran patches and regressions. > 2022-03-25 Jakub Jelinek > > PR fortran/103691 > * trans-array.cc (gfc_conv_array_initializer): If TYPE_MAX_VALUE is > smaller than TYPE_MIN_VALUE (i.e. empty array), throw the initializ= er > on the floor, if TYPE_MIN_VALUE is equal to TYPE_MAX_VALUE, use jus= t > the TYPE_MIN_VALUE as index instead of RANGE_EXPR. I am not sure whether "throw the initializer on the floor" is the best word= ing for a changelog. I think I prefer a wording like "ignore the initializer" o= r another less idiomatic expression. And I think a ';' before the second 'if' also increases readability. Tobias > --- gcc/fortran/trans-array.cc.jj 2022-02-04 14:36:55.113603791 +0100 > +++ gcc/fortran/trans-array.cc 2022-03-24 16:14:58.334498775 +0100 > @@ -6267,10 +6267,17 @@ gfc_conv_array_initializer (tree type, g > else > gfc_conv_structure (&se, expr, 1); > > - CONSTRUCTOR_APPEND_ELT (v, build2 (RANGE_EXPR, gfc_array_index_typ= e, > - TYPE_MIN_VALUE (TYPE_DOMAIN (type)= ), > - TYPE_MAX_VALUE (TYPE_DOMAIN (type)= )), > - se.expr); > + if (tree_int_cst_lt (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), > + TYPE_MIN_VALUE (TYPE_DOMAIN (type)))) > + break; > + else if (tree_int_cst_equal (TYPE_MIN_VALUE (TYPE_DOMAIN (type)), > + TYPE_MAX_VALUE (TYPE_DOMAIN (type)))) > + range =3D TYPE_MIN_VALUE (TYPE_DOMAIN (type)); > + else > + range =3D build2 (RANGE_EXPR, gfc_array_index_type, > + TYPE_MIN_VALUE (TYPE_DOMAIN (type)), > + TYPE_MAX_VALUE (TYPE_DOMAIN (type))); > + CONSTRUCTOR_APPEND_ELT (v, range, se.expr); > break; > > case EXPR_ARRAY: > > Jakub > ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstra=C3=9Fe 201= , 80634 M=C3=BCnchen; Gesellschaft mit beschr=C3=A4nkter Haftung; Gesch=C3= =A4ftsf=C3=BChrer: Thomas Heurung, Frank Th=C3=BCrauf; Sitz der Gesellschaf= t: M=C3=BCnchen; Registergericht M=C3=BCnchen, HRB 106955