Bug 78219

Summary: [F08] specifying the kind of a FORALL index in the header
Product: gcc Reporter: janus
Component: fortranAssignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal CC: juergen.reuter, kargl
Priority: P3 Keywords: rejects-valid
Version: 7.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2016-11-05 00:00:00
Bug Depends on:    
Bug Blocks: 39627, 44646    

Description janus 2016-11-05 11:58:33 UTC
The following is supposed to be valid Fortran 2008 code, IIUC:

program forall_2008

  forall (integer(kind=4) :: i = 1:10)
  end forall


However, gfortran currently throws a "Syntax error in FORALL statement".
Comment 1 janus 2016-11-05 12:12:13 UTC
My version of the Fortran 2008 standard has:

R752 forall-header is ( [ type-spec :: ] forall-triplet-spec-list [, scalar-mask-expr ] )


C735 (R752) type-spec shall specify type integer.

Actually it seems that not only specifying a kind is new, but specifying the type at all (which is restricted to integer anyway).

gfortran also rejects this simpler version (which only specifies the type, but no explicit kind):

  forall (integer :: i = 1:10)
Comment 2 Dominique d'Humieres 2016-11-05 14:00:52 UTC
Comment 3 kargl 2016-11-05 15:26:51 UTC
See array.c(gfc_match_array_constructor) for code to match
a type spec in an array constructor.  Looks like a copy and
paste with an additional check for INTEGER to 
match.c:match_forall_header mamy fix this bug.
Comment 4 janus 2018-04-18 19:59:01 UTC
Note: These things (R752 and C735) also apply to DO CONCURRENT (PR 44646).