https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101652
Bug ID: 101652 Summary: Audit uses of general purpose matching routine gfc_match with code %v Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: anlauf at gcc dot gnu.org Target Milestone: --- The purpose of this PR is a reminder of the discussion during the review of patches for pr101564, see https://gcc.gnu.org/pipermail/fortran/2021-July/056273.html and related mails. E.g. Fortran 2018 has: 9.2 Variable R902 variable is designator or function-reference C901 (R902) designator shall not be a constant or a subobject of a constant. C902 (R902) function-reference shall have a data pointer result. A variable is either the data object denoted by designator or the target of the pointer resulting from the evaluation of function-reference; this pointer shall be associated. ... The current implementation of gfc_match invokes gfc_match_variable when it encounters the code %v, which does not handle function-references. One possible solution is to audit the code and to replace uses of %v by %e and subsequently check using gfc_check_vardef_context.