[Patch/gfortran] Empty array constructors

Erik Edelmann eedelman@acclab.helsinki.fi
Fri Jun 3 22:21:00 GMT 2005


The following code 

        program hum
            print *, (//)
        end program hum

currently gives an ICE:

        hum.f90: In function 'MAIN__':
        hum.f90:3: internal compiler error: in gfc_typenode_for_spec, at fortran/trans-types.c:631

The code is invalid, as discussed in recent thread ("Zero-size array
literal") in comp.lang.fortran, but a meaningful error message would still
be better than an ICE. The attached patch fixes this.

Bubblestrapped and reg. tested on Linux-x86, on 4.0 and mainline.   Please
commit if OK.


Changelog entry for patch:

2005-06-04 Erik Edelmann <erik.edelmann@iki.fi>
        * array.c (gfc_match_array_constructor) Treat empty array
          constructors as an syntax error.



Changelog entry for test case (test case attached):

2005-06-04 Erik Edelmann <erik.edelmann@iki.fi>
        * gfortran.dg/array_constructor_3.f90: New test



        Erik
-------------- next part --------------
Index: gcc/fortran/array.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/fortran/array.c,v
retrieving revision 1.15
diff -r1.15 array.c
890c890
<     goto empty;			/* Special case */
---
>     goto syntax;
914d913
< empty:
-------------- next part --------------
! { dg-do compile }
! Check that empty array constructors are rejected
program hum
    print *, (//)  { dg-error "Syntax error" }
end program hum


More information about the Fortran mailing list