[PATCH] PR47040 - Make error message for empty array constructor more helpful/correct

Steve Kargl sgk@troutmask.apl.washington.edu
Sat Apr 9 15:39:00 GMT 2016


On Sat, Apr 09, 2016 at 12:28:12PM +0200, Dominique d'Humières wrote:
> >>> On Wed, Apr 06, 2016 at 05:44:55PM +0200, Dominique d'Humières wrote:
> >>>> Is the following patch OK (regtested on x86_64-apple-darwin15)? Should it be back ported to the gcc-5 branch?
> >>> 
> >>> No and No.
> > Le 7 avr. 2016 à 15:59, Steve Kargl <sgk@troutmask.apl.washington.edu> a écrit :
> > 
> > The latter is obvious as this "fixes" neither a regression
> > nor documentation.  
> 
> I won’t argue.
> 
> > For the former, see Fortran 95, section 4.5.
> > 
> > -- 
> > steve
> 
> 
> Are you referring to
> 
> (a)  An empty sequence forms a zero-sized rank-one array.
> 
> (b) The type and type parameters of an array constructor are those of the ac-value expressions.
> 
> (c) something else?
> 

Fortran 95 doesn't have a type-spec in an array constructor.
Fortran 95 explicitly states

  "The type and type parameters of an array constructor are
   those of the ac-value expressions."

(/ /) is valid Fortran 95 syntax while (/ type-spec :: /) is
not valid.  type-spec was introduced in Fortran 2003.  The
error message as written is correct.

(/ /) is empty.
(/type-spec :: /) is not empty, and is  invalid Fortan 95.
(/1, 2, 3/) is not empty and has a type of INTEGER.

program foo
   call bar((/ /))
end program foo

% gfc -c -std=f95 foo.f90
foo.f90:2:17:

    call bar((/ /))
                 1
Error: Empty array constructor at (1) is not allowed

The above error is correct.  Adding any text referring
to type-spec is wrong.
 
-- 
Steve



More information about the Gcc-patches mailing list