An OPEN statement needs to either have a unit number in the first item in the list, or have a UNIT= (or NEWUNIT= in F2008) keyword somewhere else. Here is an example where the unit number is not specified, yet gfortran does not issue an error: subroutine openit implicit none open (file='x') end subroutine This was tested with version 4.4.1 on Ubuntu linux.
An additional test: with just an OPEN statement with no list, gfortran issues: In file miniopen.f90:4 open () 1 Error: Syntax error in OPEN statement at (1) While the message is technically correct, it would be more helpful if it mentioned the missing unit number.
Fortran 2008 (almost FDIS version) has: C904 (R904) If the NEWUNIT= specifier does not appear, a file-unit-number shall be specied; if the optional characters UNIT= are omitted, the file-unit-number shall be the first item in the connect-spec-list.
OK , I will see what I ca ndo.
Subject: Bug 43832 Author: jvdelisle Date: Sat Apr 24 12:04:09 2010 New Revision: 158684 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158684 Log: 2010-04-24 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR fortran/43832 * io.c (gfc_match_open): Remove branch to syntax error. Add call to gfc_error with new error message. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/io.c
Subject: Bug 43832 Author: jvdelisle Date: Sat Apr 24 12:07:07 2010 New Revision: 158685 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158685 Log: 2010-04-24 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR fortran/43832 * gfortran.dg/open_nounit.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/open_nounit.f90 Modified: trunk/gcc/testsuite/ChangeLog
Fixed on trunk. Closing
Subject: Bug 43832 Author: hp Date: Sat Apr 24 17:00:52 2010 New Revision: 158688 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158688 Log: PR fortran/43832 * gfortran.dg/fgetc_3.f90: Delete bogus test. Removed: trunk/gcc/testsuite/gfortran.dg/fgetc_3.f90 Modified: trunk/gcc/testsuite/ChangeLog