flang-compiler / f18-llvm-project

Fork of llvm/llvm-project for f18. In sync with f18-mlir and f18.
http://llvm.org
28 stars 16 forks source link

Flang demands a FILE specifier when STATUS='NEW' #362

Open sscalpone opened 4 years ago

sscalpone commented 4 years ago

From NASTRAN-95/mis/endsys.f

% cat o.f
        OPEN (UNIT=97,ACCESS='SEQUENTIAL',STATUS='NEW',ERR=64)
64      CONTINUE
        END
% gfortran -c o.f
o.f:1:72:

         OPEN (UNIT=97,ACCESS='SEQUENTIAL',STATUS='NEW',ERR=64)
                                                                        1
Warning: The STATUS specified in OPEN statement at (1) is ‘NEW’ and no FILE specifier is present
% ifort -c o.f
% flang -c o.f
o.f:1:9: error: If STATUS='NEW' appears, FILE must also appear
          OPEN (UNIT=97,ACCESS='SEQUENTIAL',STATUS='NEW',ERR=64)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
vdonaldson commented 4 years ago

This is an f18 program requirement, which also appears in various forms in f08, f03, f90, and f77. Here are excerpts from f18 and f77. Is there a reasonable interpretation for this statement that would allow it to be executed as an extension? (The processor can't determine all violations at compile time, which is presumably why this is a program requirement, rather than a constraint.)

f18 -- 12.5.6.10 FILE= specifier in the OPEN statement

This specifier shall appear if the STATUS= specifier has the value NEW or REPLACE. This specifier shall not appear if the STATUS= specifier has the value SCRATCH. If the STATUS= specifier has the value OLD, this specifier shall appear unless the unit is connected and the file connected to the unit exists. If this specifier is omitted and the unit is not connected to a file, the STATUS= specifier shall be specified with a value of SCRATCH; in this case, the connection is made to a processor-dependent file.

f77 -- 12.10.1 OPEN Statement

STATUS = sta

sta is a character expression whose value when any trailing blanks are removed is OLD, NEW, SCRATCH, or UNKNOWN. If OLD or NEW is specified, a FILE= specifier must be given.

schweitzpgi commented 4 years ago

Document somewhere and close?

sscalpone commented 4 years ago

I've assigned it to me to create an Issue for NASTRAN and then close.

schweitzpgi commented 3 years ago

Closing as this has been sitting here for a while.

sscalpone commented 3 years ago

I've got it.