This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] PR47040 - Make error message for empty array constructor more helpful/correct
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: "Dominique d'Humières" <dominiq at lps dot ens dot fr>
- Cc: Tobias Burnus <burnus at net-b dot de>, fortran at gcc dot gnu dot org, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 9 Apr 2016 09:13:15 -0700
- Subject: Re: [PATCH] PR47040 - Make error message for empty array constructor more helpful/correct
- Authentication-results: sourceware.org; auth=none
- References: <4C6F6CD1-9AAB-459A-9182-655EDB56C437 at lps dot ens dot fr> <20160407054844 dot GA48073 at troutmask dot apl dot washington dot edu> <9CC17A2B-DC0A-40B4-9696-038170F0F8B7 at lps dot ens dot fr> <20160407135902 dot GA50811 at troutmask dot apl dot washington dot edu> <8E1D4A5A-F220-4A32-B0F2-EC8CC4BF327E at lps dot ens dot fr> <20160409153907 dot GA47292 at troutmask dot apl dot washington dot edu> <7EBFF209-4B2B-4C33-BCA0-7F3996AA3E56 at lps dot ens dot fr>
On Sat, Apr 09, 2016 at 05:56:12PM +0200, Dominique d'Humières wrote:
>
> > (/ /) is valid Fortran 95 syntax
> > ...
> >
> > 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.
>
> Well the two assertions look contradictory: if (/ /) is valid
> Fortran 95 syntax why is it not allowed?
It is valid syntax because of
"An empty sequence forms a zero-sized rank-one array."
It seems that J3 saw the error in their ways as (/ /) is clearly
an empty array constructor, and fixed the possibility of creating
a typeless zero-sized, rank-one array.
> > Adding any text referring
> > to type-spec is wrong.
> >
>
> Are you considering (/ ( i, i = 1, 0 ) /) as non empty?
>
It is a zero-sized rank-one array with type INTEGER.
"The type and type parameters of an array constructor are those
of the ac-value expressions."
ac-value is expr
or ac-implied-do
"If an ac-value is an ac-implied-do, it is expanded to form an ac-value
sequence under the control of the ac-do-variable..."
--
Steve