This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Implementation for ALLOCATE(..., SOURCE=expression)


On 08/18/2009 08:29 AM, Steve Kargl wrote:
> I'll further note that I could be reading the EBNF in the F2003
> standard incorrectly.  For derived type type-spec in ALLOCATE,
> the correct form is
>
>   type(xyz), allocatable :: a
>   allocate(xyz :: a(3))
>
> That is, allocate(type(xyz) :: a(3) is not valid, and
> gfc_match_type_spec() does not match the correct form.
>   

To my surprise that is indeed the case - and ifort agrees also with this:

R623 allocate-stmt is ALLOCATE ( [ type-spec :: ] allocation-list
                                 [, alloc-opt-list ] )

R401 type-spec is intrinsic-type-spec
               or derived-type-spec

R455 derived-type-spec   is type-name [ ( type-param-spec-list ) ]


One should note that Fortran 2003 has:

"C424 (R430) A derived type type-name shall not be DOUBLEPRECISION or
the same as the name of any intrinsic type defined in this standard."

Thus using   allocate(integer :: a(a))  is not ambiguous while allowing,
e.g, BYTE as integer type is problematic as "TYPE byte" is also allowed.

(In principle,  "type(INTEGER)" would also be possible - and useful for
some automatic code generators - but it never made it into the standard.)

Tobias


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]