[J3] Statement and construct entity typing
Steve Lionel
steve at stevelionel.com
Mon Apr 23 17:31:25 EDT 2018
Consider the following:
integer :: foo(6)
integer, parameter :: i = 42
do concurrent (i=1:size(foo))
foo(i) = i
end do
print *, "foo = ", foo
end
Several compilers complain about the appearance of named constant i in
the concurrent header. 18-007r1 19.4p5 says:
The name of a variable that appears as an index-name in a DO CONCURRENT
construct, FORALL statement, or
FORALL construct has a scope of the statement or construct. It is a
scalar variable. If integer-type-spec appears in
concurrent-header it has the specified type and type parameters;
otherwise it has the type and type parameters
that it would have if it were the name of a variable in the innermost
executable construct or scoping unit that
includes the DO CONCURRENT or FORALL, and this type shall be integer
type. It has no other attributes.
The appearance of a name as an index-name in a DO CONCURRENT construct,
FORALL statement, or FORALL
construct is not an implicit declaration of a variable whose scope is
the scoping unit that contains the statement or
construct.
When I complained about the error to one vendor, this paragraph was
cited and the explanation was that since i is a named constant and not a
variable, this paragraph doesn't apply. If so, then there is indeed "no
meaning" defined for the code in question so an error is appropriate.
But this feels wrong to me - the paragraph says "if it were the name of
a variable" which doesn't necessarily imply to me that it must be a
variable and not some other typed entity. Since all that is being taken
is the type and type parameters, why does it matter if it's a variable
or some other typed entity?
p4 has similar wording for statement entities.
I'd appreciate others' thoughts on this.
Steve
More information about the J3
mailing list