This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Committed] PR fortran/88205 -- Check NEWUNIT after STATUS
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Sun, 9 Dec 2018 17:27:28 -0800
- Subject: [Committed] PR fortran/88205 -- Check NEWUNIT after STATUS
- Reply-to: sgk at troutmask dot apl dot washington dot edu
The attach patch moves the checks on NEWUNIT to
after the checks on STATUS.
2018-12-09 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/88205
* io.c (gfc_match_open): Move NEWUNIT checks to after STATUS checks.
2018-12-09 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/88205
* gfortran.dg/pr88205.f90: New unit.
--
Steve
Index: gcc/fortran/io.c
===================================================================
--- gcc/fortran/io.c (revision 266929)
+++ gcc/fortran/io.c (working copy)
@@ -2150,33 +2150,6 @@ gfc_match_open (void)
warn = (open->err || open->iostat) ? true : false;
- /* Checks on NEWUNIT specifier. */
- if (open->newunit)
- {
- if (open->unit)
- {
- gfc_error ("UNIT specifier not allowed with NEWUNIT at %C");
- goto cleanup;
- }
-
- if (!open->file && open->status)
- {
- if (open->status->expr_type == EXPR_CONSTANT
- && gfc_wide_strncasecmp (open->status->value.character.string,
- "scratch", 7) != 0)
- {
- gfc_error ("NEWUNIT specifier must have FILE= "
- "or STATUS='scratch' at %C");
- goto cleanup;
- }
- }
- }
- else if (!open->unit)
- {
- gfc_error ("OPEN statement at %C must have UNIT or NEWUNIT specified");
- goto cleanup;
- }
-
/* Checks on the ACCESS specifier. */
if (open->access && open->access->expr_type == EXPR_CONSTANT)
{
@@ -2499,6 +2472,33 @@ gfc_match_open (void)
"cannot have the value SCRATCH if a FILE specifier "
"is present");
}
+ }
+
+ /* Checks on NEWUNIT specifier. */
+ if (open->newunit)
+ {
+ if (open->unit)
+ {
+ gfc_error ("UNIT specifier not allowed with NEWUNIT at %C");
+ goto cleanup;
+ }
+
+ if (!open->file && open->status)
+ {
+ if (open->status->expr_type == EXPR_CONSTANT
+ && gfc_wide_strncasecmp (open->status->value.character.string,
+ "scratch", 7) != 0)
+ {
+ gfc_error ("NEWUNIT specifier must have FILE= "
+ "or STATUS='scratch' at %C");
+ goto cleanup;
+ }
+ }
+ }
+ else if (!open->unit)
+ {
+ gfc_error ("OPEN statement at %C must have UNIT or NEWUNIT specified");
+ goto cleanup;
}
/* Things that are not allowed for unformatted I/O. */
Index: gcc/testsuite/gfortran.dg/pr88205.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr88205.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr88205.f90 (working copy)
@@ -0,0 +1,14 @@
+! { dg-do compile }
+! PR fortran/88205
+subroutine s1
+ real, parameter :: status = 0
+ open (newunit=n, status=status) ! { dg-error "STATUS requires" }
+end
+subroutine s2
+ complex, parameter :: status = 0
+ open (newunit=n, status=status) ! { dg-error "STATUS requires" }
+end
+program p
+ logical, parameter :: status = .false.
+ open (newunit=a, status=status) ! { dg-error "STATUS requires" }
+end