Bug 43832 - OPEN statement not diagnosing missing unit number
Summary: OPEN statement not diagnosing missing unit number
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.4.1
: P3 normal
Target Milestone: 4.6.0
Assignee: Jerry DeLisle
URL:
Keywords: accepts-invalid, diagnostic
Depends on:
Blocks:
 
Reported: 2010-04-21 13:47 UTC by Walter Spector
Modified: 2010-04-24 12:09 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-04-22 00:29:04


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Walter Spector 2010-04-21 13:47:02 UTC
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.
Comment 1 Walter Spector 2010-04-21 14:05:03 UTC
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.
Comment 2 Tobias Burnus 2010-04-21 14:09:38 UTC
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.
Comment 3 Jerry DeLisle 2010-04-22 00:29:01 UTC
OK , I will see what I ca ndo.
Comment 4 Jerry DeLisle 2010-04-24 12:04:36 UTC
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

Comment 5 Jerry DeLisle 2010-04-24 12:07:30 UTC
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

Comment 6 Jerry DeLisle 2010-04-24 12:09:25 UTC
Fixed on trunk. Closing
Comment 7 Hans-Peter Nilsson 2010-04-24 17:01:14 UTC
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