Bug 101652

Summary: Audit uses of general purpose matching routine gfc_match with code %v
Product: gcc Reporter: anlauf
Component: fortranAssignee: Not yet assigned to anyone <unassigned>
Status: UNCONFIRMED ---    
Severity: normal    
Priority: P3    
Version: 12.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:

Description anlauf 2021-07-27 21:07:42 UTC
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.