From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7AC123858C27; Wed, 27 Oct 2021 20:43:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7AC123858C27 From: "aldot at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/102973] New: possible inconsistency in procptr_assignment handling when matching ASSOCIATE Date: Wed, 27 Oct 2021 20:43:33 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: aldot at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Oct 2021 20:43:33 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102973 Bug ID: 102973 Summary: possible inconsistency in procptr_assignment handling when matching ASSOCIATE Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: aldot at gcc dot gnu.org Target Milestone: --- As noted in https://gcc.gnu.org/pipermail/fortran/2018-September/050809.html i spotted one (pre-existing) possible inconsistency that i did overlook back then: gfc_match_associate () reads ... if (gfc_match (" %e", &newAssoc->target) !=3D MATCH_YES) { /* Have another go, allowing for procedure pointer selectors. */ gfc_matching_procptr_assignment =3D 1; if (gfc_match (" %e", &newAssoc->target) !=3D MATCH_YES) { gfc_error ("Invalid association target at %C"); goto assocListError; } gfc_matching_procptr_assignment =3D 0; } i.e. we retry a match, but in the second attempt we turn on procptr assignment matching and if that works, we turn procptr assignment matching off again. But if we fail that retry, we forget to turn it off again. I suppose we should: $ svn diff -x -p gcc/fortran/match.c Index: gcc/fortran/match.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc/fortran/match.c (revision 264040) +++ gcc/fortran/match.c (working copy) @@ -1898,13 +1898,16 @@ gfc_match_associate (void) if (gfc_match (" %e", &newAssoc->target) !=3D MATCH_YES) { /* Have another go, allowing for procedure pointer selectors. */ + match m; + gfc_matching_procptr_assignment =3D 1; - if (gfc_match (" %e", &newAssoc->target) !=3D MATCH_YES) + m =3D gfc_match (" %e", &newAssoc->target); + gfc_matching_procptr_assignment =3D 0; + if (m !=3D MATCH_YES) { gfc_error ("Invalid association target at %C"); goto assocListError; } - gfc_matching_procptr_assignment =3D 0; } newAssoc->where =3D gfc_current_locus; Untested. Maybe someone wants to give it a whirl... If it wrecks havoc then leaving it set deliberately deserves at least a comment. PS: It would be nice to get rid of gfc_matching_procptr_assignment, gfc_matching_ptr_assignment, gfc_matching_prefix, FWIW.=