f18
f18 copied to clipboard
Implement validity checks for variable definition contexts
There are situations in a Fortran program which imply the modification of variables. These are known as “variable definition contexts”. Section 19.6.7 specifies 15 such contexts. One example is the variable that appears on the left side of an assignment-stmt.
There are also sections that prohibit certain entities from appearing in variable definition contexts. An example of this is a dummy argument with the attribute INTENT(IN). When performing semantic checks on constructs that require entities that can appear in variable definition contexts, we need to verify that the actual entities were not prohibited from appearing in such contexts.
Section 19.6.7 lists three sections that describe entities that cannot appear in variable definition contexts: 8.5.10(INTENT(IN) dummy arguments), 8.5.15 (nonpointer MODULE entities with the PROTECTED attribute), and 15.7 (nonlocal data in a PURE subprogram). But closer examination of the standard reveals more situations where entities cannot appear in variable definition contexts. One example is constraint C1101, which states that an associate-name that does not denote a variable shall not appear in a variable definition context.
I've attached several tests that should emit error messages because they contain assignment statements where the left hand side of the statement is a name prohibited from appearing in a variable definition context.
The purpose of this issue is to implement the checking necessary to determine if a name can appear in a variable definition context. Once that has been done, we can resolve this issue. We can use that code to test for the 15 cases listed in section 19.6.7
c1610.f90.txt c844.f90.txt c857.f90.txt c1101.f90.txt c1158.f90.txt c1594.f90.txt c1605.f90.txt c1606.f90.txt c1609.f90.txt
These checks are mostly implemented as part of pull request #596. Note that the only place where these checks are currently referenced is in the semantic processing for locality-specs. Note also that there are still some checks still to be done, relating to constraint C1594. Specifically, we do not yet check for coindexed objects being referenced from PURE procedures.