]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Allow opening file on multiple units
authorJanne Blomqvist <jb@gcc.gnu.org>
Wed, 15 May 2019 18:02:36 +0000 (21:02 +0300)
committerJanne Blomqvist <jb@gcc.gnu.org>
Wed, 15 May 2019 18:02:36 +0000 (21:02 +0300)
As of Fortran 2018 it's allowed to open the same file on multiple
units.

libgfortran/ChangeLog:

2019-05-15  Janne Blomqvist  <jb@gcc.gnu.org>

PR fortran/90461
        * io/open.c (new_unit): Don't check if the file is already open
for F2018.

testsuite/ChangeLog:

2019-05-15  Janne Blomqvist  <jb@gcc.gnu.org>

PR fortran/90461
        * gfortran.dg/open_errors_2.f90: Add -std=f2008, adjust line number.
* gfortran.dg/open_errors_3.f90: New test.

From-SVN: r271260

gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/open_errors_2.f90
gcc/testsuite/gfortran.dg/open_errors_3.f90 [new file with mode: 0644]
libgfortran/ChangeLog
libgfortran/io/open.c

index a85e383f8580f1654020fef6a142450fd61a06fa..ffba7ba33394fe459c501c3447396048b18c59a3 100644 (file)
@@ -1,3 +1,9 @@
+2019-05-15  Janne Blomqvist  <jb@gcc.gnu.org>
+
+       PR fortran/90461
+        * gfortran.dg/open_errors_2.f90: Add -std=f2008, adjust line number.
+       * gfortran.dg/open_errors_3.f90: New test.
+
 2019-05-15  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR target/89021
index 5b418349e1983466e697dbee83356216aaf19e4a..72d63bb3a39f6936e063c4aca974940ffe1f3e6e 100644 (file)
@@ -1,6 +1,7 @@
 ! { dg-do run }
+! { dg-options "-std=f2008" }
 ! { dg-shouldfail "runtime error" }
-! { dg-output "At line 13.*File already opened" }
+! { dg-output "At line 14.*File already opened" }
 
 ! PR 65563 - this used to segfault for some versions.
   variable_1 = 0
diff --git a/gcc/testsuite/gfortran.dg/open_errors_3.f90 b/gcc/testsuite/gfortran.dg/open_errors_3.f90
new file mode 100644 (file)
index 0000000..da94956
--- /dev/null
@@ -0,0 +1,11 @@
+! { dg-do  run }
+! PR 90461 Open file on multiple units as of F2018
+program openmult
+  implicit none
+  character(len=*), parameter :: fname="pr90461.dat"
+  open(10, file=fname, form="unformatted")
+  open(11, file=fname, form="unformatted")
+  close(11)
+  close(10, status="delete")
+end program openmult
+! { dg-final { remote_file build delete "pr90461.dat" } }
index 72b70a0c559411bf53bde462d2cbc00757f83f8c..4b5194f4406b7b1c0d192257147a41a8fddbd64d 100644 (file)
@@ -1,3 +1,9 @@
+2019-05-15  Janne Blomqvist  <jb@gcc.gnu.org>
+
+       PR fortran/90461
+        * io/open.c (new_unit): Don't check if the file is already open
+       for F2018.
+
 2019-05-02  Jakub Jelinek  <jakub@redhat.com>
 
        * Makefile.am (gfor_cdir): Remove $(MULTISUBDIR).
index b48afabf7a3daebc68efbe36679cefe91821d197..d3bb11f5965113417849cb2c6214c8f6f2d713ef 100644 (file)
@@ -515,7 +515,8 @@ new_unit (st_parameter_open *opp, gfc_unit *u, unit_flags *flags)
      Do not error if opening file preconnected to stdin, stdout, stderr.  */
 
   u2 = NULL;
-  if ((opp->common.flags & IOPARM_OPEN_HAS_FILE) != 0)
+  if ((opp->common.flags & IOPARM_OPEN_HAS_FILE) != 0
+      && !(compile_options.allow_std & GFC_STD_F2018))
     u2 = find_file (opp->file, opp->file_len);
   if (u2 != NULL
       && (options.stdin_unit < 0 || u2->unit_number != options.stdin_unit)