This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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] PR47040 - Make error message for empty array constructor more helpful/correct


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


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