From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by sourceware.org (Postfix) with ESMTPS id B3AF63854801; Fri, 26 Mar 2021 06:48:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B3AF63854801 Received: by mail-lf1-x12a.google.com with SMTP id b4so6105577lfi.6; Thu, 25 Mar 2021 23:48:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EEd2FxiOvgOk/aBrjpIxNOYWVelXrbZOGal1jqXvZ3Y=; b=RNlG5Mm6wrsTvssLWiynMWlP4/dJ9kK3KF6gb8ANVt/gkuyd4v7lCq1KGkuwm3YYAI ogD6fmdoRCNQ3GnVfe1QVIO6E5HbvI1mjR+epyyBWtJepMYuYHFN+5KUuZCVtiEobQRP bSRKjapELcL4xsF953Nhx2yabflTRjPHkQ2C/QX41dtr69szK4QOmZSNENRKSjdQ6nCv jLsKNtTK8feLLMu2WzjhKnaddY94pzN9UHOBEV+/nsL3/mHPezeheLJcT7U8ulVH93X1 MM9+//7f7kbSxrBJFZAZIoCDWwG5l2GMyLrcCk9R+cFoMoeMrOo3YdBoPZb0MkzPFT83 2XDA== X-Gm-Message-State: AOAM532mm7sFB+3yIIzw2aTuSU19YSTFC43shh9FHtZXr8tiG0+hZ0ZC iGgFd8ZnGR8Fn+zvJ333qcC72TAEyn3D94YNH3QlHrk7 X-Google-Smtp-Source: ABdhPJyGHsS3xRs7G5XitJ9EqV4smr3x3KGL3InwfGrWEYcltUFxaa1pF7j/RvgB7iM8TaBqdMDyvDdVxNGlG1ldhvg= X-Received: by 2002:a05:6512:b90:: with SMTP id b16mr6677484lfv.209.1616741310320; Thu, 25 Mar 2021 23:48:30 -0700 (PDT) MIME-Version: 1.0 References: <7f4a2fe7-4880-312b-4a05-9578fa431e7c@codesourcery.com> <31957d7d-6881-5821-cef6-7980c0231ab4@codesourcery.com> In-Reply-To: <31957d7d-6881-5821-cef6-7980c0231ab4@codesourcery.com> From: Paul Richard Thomas Date: Fri, 26 Mar 2021 06:48:18 +0000 Message-ID: Subject: Re: [Patch] Fortran: Fix intrinsic null() handling [PR99651] To: Tobias Burnus Cc: gcc-patches , fortran X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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, 26 Mar 2021 06:48:36 -0000 Hi Tobias, Please go ahead and commit the patch. I think that your analysis is correct about expr_null and that your patch is the best way to deal with the problem. Best regards Paul On Tue, 23 Mar 2021 at 17:54, Tobias Burnus wrote= : > Hi Paul, > > On 23.03.21 18:34, Paul Richard Thomas wrote: > > I took something of a detour in reviewing this patch. Although short, > > understanding it is not straightforward! > > I concur =E2=80=93 and as I wrote both in the patch email and in the PR, = it is > not straight forward which message is showing with which setting. > > Actually, I think there are many straight-forward ways to fix it > "properly" but they tend to hide some nicer error messages in favour of > a more generic one. Only by taking into account all the diagnostic and > hidden/delayed diagnostic, the patch becomes complex. (-: > > > Your patch works as advertised and regtests OK (with the patch for > > PR93660 on board as well). Is NULL the only case where this can happen? > > I am not sure whether any other code would profit form getting one of > the attributes conditionally assigned in intrinsic.c. > > Otherwise, I think that's the only code which verifies like that it in > such a way whether an intrinsic function was used. I think the reason > that it does so is because 'null' is turned early during parsing into > EXPR_NULL, which is not a function and, hence, bypasses some of the > later checking code in resolve.c. > > > > Just to aid my understanding, I tried: > > diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c > > > > --- a/gcc/fortran/primary.c > > +++ b/gcc/fortran/primary.c > > @@ -3922,6 +3922,9 @@ gfc_match_rvalue (gfc_expr **result) > > if (m =3D=3D MATCH_NO) > > m =3D MATCH_YES; > > > > + if (!strcmp (sym->name, "NULL") || !strcmp (sym->name, "null")) > > + sym->attr.intrinsic =3D 1; > > + > > break; > > > > generic_function: > > > > which also works and regtests OK. (I couldn't remember whether > > sym->name is upper or lower case at this stage.) > > Should be always lowercase, I think. But I am also not sure that your > aid-understanding patch will work correctly with 'external null' or a > use-/host-associated/interface 'null' procedure or some array variable. > Inside intrinsic.c, we are at least sure that we did get an intrinsic > function after having passed all intrinsic checks. > > Tobias > > ----------------- > Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 M=C3=BCnchen > Registergericht M=C3=BCnchen HRB 106955, Gesch=C3=A4ftsf=C3=BChrer: Thoma= s Heurung, Frank > Th=C3=BCrauf > --=20 "If you can't explain it simply, you don't understand it well enough" - Albert Einstein