]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2018-12-09 Steven G. Kargl <kargl@gcc.gnu.org>
authorkargl <kargl@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 9 Dec 2018 23:49:14 +0000 (23:49 +0000)
committerkargl <kargl@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 9 Dec 2018 23:49:14 +0000 (23:49 +0000)
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: svn+ssh://gcc.gnu.org/svn/gcc/trunk@266936 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/io.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr88205.f90 [new file with mode: 0644]

index f5c2f01bab46f154c488efa804e3ce2faa0fdd9e..031a988e8c797034ccda266adf84b9b5cb322075 100644 (file)
@@ -1,3 +1,8 @@
+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
index 0aa31bb6a4f7830df35ebd71a91b5b81d4919bcb..8008f92f38c2d2d06b9271c8db9b1dd6997e4e27 100644 (file)
@@ -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
index 043c5ea2ef289b45ca0df46a7bbb1bf62225d8b4..7b90d56c769ae843864f526abef1b8dd53d2c69f 100644 (file)
@@ -1,3 +1,8 @@
+2018-12-09  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/88205
+       * gfortran.dg/pr88205.f90: New unit.
+
 2018-12-09  Iain Buclaw  <ibuclaw@gdcproject.org>
 
        PR d/88039
diff --git a/gcc/testsuite/gfortran.dg/pr88205.f90 b/gcc/testsuite/gfortran.dg/pr88205.f90
new file mode 100644 (file)
index 0000000..d9e0806
--- /dev/null
@@ -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