diff options
author | Steven G. Kargl <kargl@gcc.gnu.org> | 2018-12-10 01:01:01 +0000 |
---|---|---|
committer | Steven G. Kargl <kargl@gcc.gnu.org> | 2018-12-10 01:01:01 +0000 |
commit | f87b65d43a390814ac324c07bd54cbfd80d5dcff (patch) | |
tree | 8928f03077d622116806e26b3cc1b2adbebccaee | |
parent | 09a10b2190545287613ca0f4feb4f0357dd184d0 (diff) |
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.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gcc-8-branch@266940 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/fortran/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/fortran/io.c | 54 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pr88205.f90 | 14 |
4 files changed, 51 insertions, 27 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 46430e74d83..f8c65e7cd0f 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,5 +1,10 @@ 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/88206 * match.c (gfc_match_type_spec): REAL can be an intrinsic function. diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c index 0aa31bb6a4f..8008f92f38c 100644 --- a/gcc/fortran/io.c +++ b/gcc/fortran/io.c @@ -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) { @@ -2501,6 +2474,33 @@ gfc_match_open (void) } } + /* 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. */ if (open->form && open->form->expr_type == EXPR_CONSTANT && (open->delim || open->decimal || open->encoding || open->round diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4351da403be..32817721d2e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2018-12-09 Steven G. Kargl <kargl@gcc.gnu.org> + PR fortran/88205 + * gfortran.dg/pr88205.f90: New unit. + +2018-12-09 Steven G. Kargl <kargl@gcc.gnu.org> + PR fortran/88206 * gfortran.dg/pr88206.f90: New test. diff --git a/gcc/testsuite/gfortran.dg/pr88205.f90 b/gcc/testsuite/gfortran.dg/pr88205.f90 new file mode 100644 index 00000000000..d9e08069109 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr88205.f90 @@ -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 |