https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102973
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) != MATCH_YES) { /* Have another go, allowing for procedure pointer selectors. */ gfc_matching_procptr_assignment = 1; if (gfc_match (" %e", &newAssoc->target) != MATCH_YES) { gfc_error ("Invalid association target at %C"); goto assocListError; } gfc_matching_procptr_assignment = 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 =================================================================== --- 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) != MATCH_YES) { /* Have another go, allowing for procedure pointer selectors. */ + match m; + gfc_matching_procptr_assignment = 1; - if (gfc_match (" %e", &newAssoc->target) != MATCH_YES) + m = gfc_match (" %e", &newAssoc->target); + gfc_matching_procptr_assignment = 0; + if (m != MATCH_YES) { gfc_error ("Invalid association target at %C"); goto assocListError; } - gfc_matching_procptr_assignment = 0; } newAssoc->where = 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.