From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by sourceware.org (Postfix) with ESMTPS id F3FF3383E824; Fri, 25 Mar 2022 12:13:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F3FF3383E824 Received: by mail-ed1-x52e.google.com with SMTP id c62so9005495edf.5; Fri, 25 Mar 2022 05:13:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=iIfk0gZlqJZvh1sYj9Px/IjZ8paXXQusVNcUJNzKGGQ=; b=M7cCYcmHQ3a3bYUZ9Xv88SYjTW14LyAd4IcACSw4n8GsG2eNoczTqBknaWY+IMnfm+ VIeI+Wt+/ygMOkh43K+bsSrE/e2mdVznbdX9W4J1gs6vRqbUKzlig5SIlPCwSc0bZmh4 7tVJeqWwW2mxbqahmNQfyBWws3BsJGFbwiZiib4Zd3rw+eanL5f6UehJtgIT95GeZ6Ao yzqw4zGkf5xdDSaV87Jj4ixzK3sRDHafzp1qKK4YfVwWz5oTDfqwknnVCIq4tWuaCc+1 B5zWQOo8RQ3RdsDQugMn/Y+7ugDS6UYYO6CvtC1GF6VYnOHGbMoYThX/P+Sy2W2HGPjf uWxg== X-Gm-Message-State: AOAM533n/rex+6gx5kF11NegtwQ0FyFs4a6bGHDdI19pRIQIHl36kt75 gatup0vfGm9X0c4fUEIzROsgF2QCiSuLUjbeV5I= X-Google-Smtp-Source: ABdhPJxignWmie5Htcm/BzPrQQxWIqYKwmei9J6qNR0ar7kJiUCq+FVOSZtezE31n9TlySEifbvoKzpgqQRoSPuUOvA= X-Received: by 2002:a50:ec18:0:b0:419:3af:5736 with SMTP id g24-20020a50ec18000000b0041903af5736mr12742545edr.215.1648210397626; Fri, 25 Mar 2022 05:13:17 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Richard Biener Date: Fri, 25 Mar 2022 13:13:06 +0100 Message-ID: Subject: Re: [PATCH] fortran: Fix up initializers of param(0) PARAMETERs [PR103691] To: Jakub Jelinek Cc: Tobias Burnus , "fortran@gcc.gnu.org" , GCC Patches Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 12:13:21 -0000 On Fri, Mar 25, 2022 at 12:34 PM Jakub Jelinek wrote: > > On Fri, Mar 25, 2022 at 12:16:40PM +0100, Richard Biener wrote: > > On Fri, Mar 25, 2022 at 11:13 AM Tobias Burnus wrote: > > > > > > 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= minimum. > > > > > > > > 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 initiali= zer, > > > > 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+ v= alues > > > > 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 regressi= ons. > > > > > > > 2022-03-25 Jakub Jelinek > > > > > > > > PR fortran/103691 > > > > * trans-array.cc (gfc_conv_array_initializer): If TYPE_MAX_VA= LUE is > > > > smaller than TYPE_MIN_VALUE (i.e. empty array), throw the ini= tializer > > > > on the floor, if TYPE_MIN_VALUE is equal to TYPE_MAX_VALUE, u= se just > > > > the TYPE_MIN_VALUE as index instead of RANGE_EXPR. > > > > > > I am not sure whether "throw the initializer on the floor" is the bes= t wording > > > for a changelog. I think I prefer a wording like "ignore the initiali= zer" or > > > another less idiomatic expression. And I think a ';' before the secon= d 'if' > > > also increases readability. > > > > Can there be side-effects in those initializer elements in Fortran? > > For PARAMETERs certainly not, those need to be constant. > Even otherwise, this is in a routine that does > /* Create a constructor from the list of elements. */ > tmp =3D build_constructor (type, v); > TREE_CONSTANT (tmp) =3D 1; > return tmp; > at the end so I wouldn't expect side-effects anywhere. Ah, didn't see that. > Also, I think typically in the Fortran FE side-effects would go into > se.pre and se.post sequences, not into se.expr, and this routine > doesn't emit those se.pre/se.post sequences anywhere, so presumably it > assumes they don't exist. > > What is the behavior with a RANGE_EXPR when one has { [0..10] =3D ++i; }, > is that applying the side-effects 11 times or once ? 11 times is what is documented. Richard. > > > Jakub >