This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: Constraint violation
Am 25.11.2017 um 18:11 schrieb Steve Kargl:
From F2003,
R425 length-selector is ( [ LEN = ] type-param-value )
or * char-length [ , ]
So the length-selector in the below code is '*2,'.
Hmm... I am not convinces yet. As an indication, I present
the fact that ifort doesn't reject it (but I agree that
this is not evidence in itself).
Let me try to follow the rules here (following F2003).
R501 type-declaration-stmt is declaration-type-spec [ [ , attr-spec ]
... :: ] entity-decl-list
R502 declaration-type-spec is intrinsic-type-spec
or ...
R503 attr-spec is ...
or PARAMETER
R401 is intrinsic-type-spec
or derived-type-spec
R403 intrinsic-type-spec is ...
or CHARACTER [char-selector]
R424 char-selector is length-selector
or ...
R525 length-selector is [ , LEN =type-param-value ] )
or *char-length[,]
So, what is
character*2, parameter :: c(2) = ['ab', 'cd']
?
character is clearly CHARACTER
*2 is a length-selector. But what about the rest?
One possibility is that ", parameter" is an attr-spec, the
other one is that the "," is part of a length-selector and the
"parameter" is junk.
This looks like a conflict in the grammar, based on that rather strange
optional comma.
I'd say we do not change this (because it can be parsed to something
valid), but this might definitely warrant an interp (or at least a
question on c.l.f., if we are willing to take the risk of being
lectured about PL/I).
Regards
Thomas