----- Original Message -----
From: "Anton Shterenlikht" <[log in to unmask]>
To: <[log in to unmask]>
Sent: Wednesday, November 11, 2015 12:47 AM
Subject: from CLF: Declaration ordering restrictions for named constants
> This question wasn't resolved in CLF.
> Seeking clarification here.
>
> Anton
>
> From: Ian Harvey
> Newsgroups: comp.lang.fortran
> Subject: Declaration ordering restrictions for named constants
> Date: Sun, 8 Nov 2015 14:50:36 +1100
>
> When discussing initialization in a type declaration statement, F2008
> 5.2.3 has a requirement that "if the variable is an array, it shall have
> its shape specified in either the type declaration statement or a
> previous attribute specification statement in the same scoping unit".
>
> But a constant is not a variable.
>
> So is the following conforming?
>
> INTEGER, PARAMETER :: a = [1, 2]
> DIMENSION a(2)
> END
No.
'a' is required to have its shape specified in the same statement, or in a prior statement.
Put yourself in the shoes of the compiler. When it gets to the INTEGER statement
it needs to know that 'a' has a shape (in account of the constant, which is an array).
I think that you will find it covered in 5.3.13:
"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."
[emphasis added].
The DIMENSION statement references 'a' without 'a' previously having been defined as an array.
> There is a requirement on named constants declared in parameter
> statements to have their shape specified in a prior specification
> statement (5.4.11p2), but I cannot find a similar restriction for named
> constants declared via type declaration statements.
>
> The compilers that I have access to sensibly assume such a restriction
> exists. Perhaps I have missed it.
---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com
|