* [Committed] PR fortran/88205 -- Check NEWUNIT after STATUS
@ 2018-12-10 1:27 Steve Kargl
0 siblings, 0 replies; only message in thread
From: Steve Kargl @ 2018-12-10 1:27 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 334 bytes --]
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
[-- Attachment #2: pr88205.diff --]
[-- Type: text/x-diff, Size: 2584 bytes --]
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-12-10 1:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-10 1:27 [Committed] PR fortran/88205 -- Check NEWUNIT after STATUS Steve Kargl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).