(j3.2006) host association
Robert Corbett
robert.corbett
Sat Mar 7 07:44:40 EST 2015
On comp.lang.fortran, Ian Harvey has been questioning what
the standard means by the phrase "previously defined". In
his latest post he argues and complains that the new
constraint C1215 added to 15-007 [12.4.3.4p1-, 286:19-20]
needlessly makes code that is standard conforming in
Fortran 2008 nonconforming.
As part of his argument, he points out that in most cases
the standard does not require entities made accessible by
host association to be declared before they are referenced.
Consider the module
MODULE M
TYPE T
REAL(K) C
END TYPE
TYPE(T) X
PARAMETER (K = KIND(0.0))
END
The named constant K inside the derived type definition is
host associated with the named constant K declared in the
PARAMETER statement. Therefore, the restriction in
Clause 5.5.13 [103:8-9]
A named constant shall not be referenced unless
it has been defined previously in the same
statement, defined in a prior statement, or
made accessible by use or host association.
is satisfied. Note that the restriction is also
satisfied in the module
MODULE M1
TYPE T
REAL(K) C
END TYPE
TYPE(T) X
PARAMETER (K = KIND(X%C))
END
Because the standard does not establish an interpretation for
the modified module, it is not standard conforming.
Oracle Solaris Studio Fortran does not compile either of the
modules presented. In both cases, it assumes that the name K
that appears in the derived type definition is a variable name,
and so it gives an error for the component declaration. It
would not be hard to modify Oracle Solaris Studio Fortran to
handle the first module.
Did I miss a constraint or restriction in the standard that the
modules violate?
Robert Corbett
More information about the J3
mailing list