From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id 9CCD63857C48; Fri, 19 Feb 2021 16:42:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9CCD63857C48 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=mentor.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Tobias_Burnus@mentor.com IronPort-SDR: W1e4tkOEBQuey/fHOMmKpuM8z2S5oqWxfQmaxdUCPytrGcC3VgeMl2Ynwl/AotUEAy0H0YW3k2 X4Y3yHFFKYU59anU5DGFQp4bJQlzagrYILbSdRxHzD/OuC4mmI2/x1MkiFL+oDX14uxYmd14Oo XmdIQ/aUf6qf5wVXpf6uIm6Q6bF1L+x+Qfpj/Fo0fyprJgfUv42yApWLzTKxrna8rj/c8W3b19 +ZXzXmh9AJqPKWsDHAXBIPbl9JhdZHBfFEVr6yg75RBgYtBHT3IGW0q1T3Idd4c44IoWdjyBQu Kfs= X-IronPort-AV: E=Sophos;i="5.81,189,1610438400"; d="scan'208";a="60613905" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 19 Feb 2021 08:42:33 -0800 IronPort-SDR: HV2vWXQrsMXg3QHuYTFWL+4BuxLBolmtzYnZBwdik3NicrNszdJBtAuKxp/m4C2S/pr37sIGw9 zykehh5ZFuyDvQogVsC7k2On8yZUl+bzAFvkOP520LYv98olfDIediwLgnMi0co4O8KrRxSDxG 8iUDrf87rcQwbHisQa41JvrJKlKPTe+DQNVn8ZtHDkX5AmbwBcJdUJKGdCnfhFB4tjrG8vCSM8 luMu743+wYPEusTK3vaz1bMIgaSbbtzfWrpvH9UFCAgXh79mydN+v7Ds32ARiDn5wEaU00EMdj 3Yg= Subject: Re: [patch, fortran] PR96686 Namelist group objects shall be defined before appearing in namelist To: Jerry DeLisle , gfortran CC: gcc-patches References: <61fc2d13-04fc-0262-578a-b3f48d130589@charter.net> From: Tobias Burnus Message-ID: Date: Fri, 19 Feb 2021 17:42:28 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <61fc2d13-04fc-0262-578a-b3f48d130589@charter.net> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: quoted-printable Content-Language: en-US X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-05.mgc.mentorg.com (139.181.222.5) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_SHORT, NICE_REPLY_A, SPF_HELO_PASS, 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 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, 19 Feb 2021 16:42:38 -0000 Hi Jerry, On 17.02.21 04:02, Jerry DeLisle wrote: > Attached patch adds to checks. In the case of IMPLICIT typing it > checks to see if the objects listed in the NAMELIST have defined types > andf if not, sets them to the default implicit types. > > In the case of IMPLICIT NONE, the types are required be declared > before the NAMELIST. If an object type is found to not be declared > already, an error is issued. > Regression tested. > > OK for trunk? After taking a look while being less groggy, it looks good to me, but I have a few remarks: I think it looks cleaner to swap inner/outer the conditions, i.e. if (sym->ts.type =3D=3D BT_UNKNOWN) { if (!gfc_current_ns->seen_implicit_none) ... else ... } > +++ b/gcc/testsuite/gfortran.dg/namelist_4.f90 > @@ -27,14 +27,14 @@ END module M1 > program P1 > CONTAINS > ! This has the additional wrinkle of a reference to the object. > + INTEGER FUNCTION F2() > + F2=3D1 > + END FUNCTION > INTEGER FUNCTION F1() > NAMELIST /NML3/ F2 ! { dg-error "PROCEDURE attribute conflicts" } > ! Used to ICE here > - f2 =3D 1 ! { dg-error "is not a VALUE" } > + f2 =3D 1 ! { dg-error "is not a variable" } > F1=3D1 > END FUNCTION > - INTEGER FUNCTION F2() > - F2=3D1 > - END FUNCTION > END Unless I made a mistake, there is no need to modify this testcase =E2=80=93= even with the patch, the error remains the same. However, if the "f2 =3D 1" line is removed, the previously hidden error in the NAMELIST line is shown: 'PROCEDURE attribute conflicts with NAMELIST attribute in =E2=80=98f2=E2=80=99 at (1)' is shown. I think you should retain this testcase =E2=80=93 and either add between th= e two functions a new one, copying 'f1' but with 'f2 =3D 1' removed. You then get the expected NAMELIST error. =E2=80=94 Or to add a new testcase for thi= s check. PLUS: I think it would be useful to add a test of the form: namelist /nml/ f integer :: f which then shows the new error (declared before the namelist) which is currently not checked for. * * * On 19.02.21 16:58, Jerry DeLisle wrote: > On 2/17/21 1:19 AM, Tobias Burnus wrote: >> f2 looks like a local and implicitly typed real variable. At least ifort >> compiles this program successfully. I have to admit that I am not sure about this =E2=80=93 implicit typing is = odd, if combined with host association. But I think you are right. I also got confused due to the reordering, which is not needed. Regarding: > contains > integer function f1() > !f2 =3D 1 !This gives an error trying to assign a value to a > function. Okay. Also matches ifort: "This name has already been used as an external function name." > j =3D f2 ! This is OK This one is odd =E2=80=93 you assign a function address to an integer (the compiler does the casting). ifort rejects it with: "This name has already been used as an external function name." That looks like a variant of https://gcc.gnu.org/PR98890 =E2=80=93 I added = it as additional example. Tobias ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 M=C3=BCnchen R= egistergericht M=C3=BCnchen HRB 106955, Gesch=C3=A4ftsf=C3=BChrer: Thomas H= eurung, Frank Th=C3=BCrauf