From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by sourceware.org (Postfix) with ESMTPS id EDE2A3858C83; Tue, 19 Jul 2022 19:10:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EDE2A3858C83 X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.178.29] ([79.251.12.112]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MvK4f-1nN0sg3B2n-00rHk7; Tue, 19 Jul 2022 21:10:47 +0200 Message-ID: <26b7b8f2-fd97-058c-40e1-d16b4e26880e@gmx.de> Date: Tue, 19 Jul 2022 21:09:28 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] Fortran: error recovery on invalid array reference of non-array [PR103590] Content-Language: en-US To: Mikael Morin , fortran , gcc-patches Newsgroups: gmane.comp.gcc.fortran,gmane.comp.gcc.patches References: <0342ad62-3f9c-4fbb-bd00-f4d4a6b49fc7@orange.fr> From: Harald Anlauf In-Reply-To: <0342ad62-3f9c-4fbb-bd00-f4d4a6b49fc7@orange.fr> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:MuImrJlomIuocD2wHvu/LW+Suz7qPbi4554f/Y3qA1xwYG6nHem pGQmtsJrR8btb5F0pk1hPs/tkvPalQmzpCTMzUqeCKXk2f0a+yC5WIY5P+znSyyA9oDn7aM 9J6jwOJ+fVKZsAXM6tXoHkkrMsWobAIG4xJ7FQDwENMYJWcGaagd6CdKxCj+WCmyTExZZM0 cdHoHM1MH4kprrleQcW6A== X-UI-Out-Filterresults: notjunk:1;V03:K0:4zF0LYxA6Ok=:QRgRcqxEJ2Ymd1oAn+Y9KQ +Aeguuub+xvZ7AS19rRIR0uVu+ykxoeXQi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Gf9V ujm3xquc1IIGJtbQSchSXNcegy9QHaQxXeOf5kM4J+rlZKo18x288duHw== X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Tue, 19 Jul 2022 19:10:52 -0000 Message-ID: <20220719190928.lG5O7Mn8X2V4wGyr4ck8UIE5Q1CAEqIK47gYwxxQom4@z> Hi Mikael, Am 19.07.22 um 11:03 schrieb Mikael Morin: > Hello, > > the principle looks good, but... > > Le 18/07/2022 =C3=A0 22:43, Harald Anlauf via Fortran a =C3=A9crit=C2=A0= : > >> diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc >> index 2ebf076f730..dacd33561d0 100644 >> --- a/gcc/fortran/resolve.cc >> +++ b/gcc/fortran/resolve.cc >> @@ -5004,7 +5004,11 @@ find_array_spec (gfc_expr *e) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 { >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 case REF_ARRAY: >> =C2=A0=C2=A0=C2=A0=C2=A0 if (as =3D=3D NULL) >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 gfc_internal_error ("find_array_spec():= Missing spec"); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 gfc_error ("Symbol %qs at %= L has not been declared as an array", >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 e->symtree->n.sym->name, &e->where); > > ... the error here only makes sense if the array reference follows a > variable reference.=C2=A0 If it follows a derived type component referen= ce, a > slightly different error message would be more appropriate. how detailed or tailored should the error message be, or can we just have a more generic message, like "Name at %L ...", or "Invalid subscript reference at %L"? We seem to not hit that internal error very often... I have played only little with invalid code in the present context, but often hit another code path that shows up in associate_54.f90 and gives Error: Associate-name 'state' at (1) is used as array For the testcase in the PR, Intel says: associate_59.f90(7): error #6410: This name has not been declared as an array or a function. [A] print *, [character(a(1)) :: '1'] ! { dg-error "Scalar INTEGER expression" } =2D-----------------------^ Crayftn 14.0 says: Improper ir tree in expr_semantics. print *, [character(a(1)) :: '1'] ! { dg-error "Scalar INTEGER expression" } ^ ftn-873 crayftn: ERROR P, File =3D associate_59.f90, Line =3D 7, Column = =3D 26 Invalid subscripted reference of a scalar ASSOCIATE name. gfortran's behavior during error handling is difficult to understand. While the proposed new error message is emitted for associate_54.f90, it never makes it far enough for the testcase of the present PR (associate_59.f90). Thanks, Harald