public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Allow opening file on multiple units
@ 2019-05-15 13:25 Janne Blomqvist
  2019-05-15 16:02 ` Steve Kargl
  0 siblings, 1 reply; 4+ messages in thread
From: Janne Blomqvist @ 2019-05-15 13:25 UTC (permalink / raw)
  To: fortran, gcc-patches; +Cc: Janne Blomqvist

As of Fortran 2018 it's allowed to open the same file on multiple
units.

fortran/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.

Regtested on x86_64-pc-linux-gnu, Ok for trunk?
---
 gcc/testsuite/gfortran.dg/open_errors_2.f90 |  3 ++-
 gcc/testsuite/gfortran.dg/open_errors_3.f90 | 11 +++++++++++
 libgfortran/io/open.c                       |  3 ++-
 3 files changed, 15 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/open_errors_3.f90

diff --git a/gcc/testsuite/gfortran.dg/open_errors_2.f90 b/gcc/testsuite/gfortran.dg/open_errors_2.f90
index 5b418349e19..72d63bb3a39 100644
--- a/gcc/testsuite/gfortran.dg/open_errors_2.f90
+++ b/gcc/testsuite/gfortran.dg/open_errors_2.f90
@@ -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
index 00000000000..da9495610d4
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/open_errors_3.f90
@@ -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" } }
diff --git a/libgfortran/io/open.c b/libgfortran/io/open.c
index b48afabf7a3..d3bb11f5965 100644
--- a/libgfortran/io/open.c
+++ b/libgfortran/io/open.c
@@ -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)
-- 
2.17.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Allow opening file on multiple units
  2019-05-15 13:25 [PATCH] Allow opening file on multiple units Janne Blomqvist
@ 2019-05-15 16:02 ` Steve Kargl
  2019-05-15 18:30   ` Damian Rouson
  0 siblings, 1 reply; 4+ messages in thread
From: Steve Kargl @ 2019-05-15 16:02 UTC (permalink / raw)
  To: Janne Blomqvist; +Cc: fortran, gcc-patches

On Wed, May 15, 2019 at 04:24:47PM +0300, Janne Blomqvist wrote:
> As of Fortran 2018 it's allowed to open the same file on multiple
> units.
> 
> fortran/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.
> 
> Regtested on x86_64-pc-linux-gnu, Ok for trunk?

Yes.  

-- 
Steve

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Allow opening file on multiple units
  2019-05-15 16:02 ` Steve Kargl
@ 2019-05-15 18:30   ` Damian Rouson
  2019-05-15 19:21     ` Janne Blomqvist
  0 siblings, 1 reply; 4+ messages in thread
From: Damian Rouson @ 2019-05-15 18:30 UTC (permalink / raw)
  To: Steve Kargl; +Cc: Janne Blomqvist, gfortran, gcc patches

Could someone please update the Fortran 2018 status page on the wiki
to reflect this patch?  I would volunteer to do it myself, but I've
tried on at least 3 occasions (including today) to set up an account
or generate a new password and every attempt fails with a warning that
I'm being locked out because of too many requests in a short period of
time.

Is anyone aware of other lines in the status page that can also be
updated based on recent patches.  If so, please update those too.
Keeping the wiki up-to-date would be a great time-savings to whomever
takes on responding to the Fortran compiler status survey that Ian
Chivers and Jane Sleightholme publish periodically in the ACM Fortran
Forum.  I think Paul is usually the one to respond and I know it costs
him a great deal of time to do so.   I wish I could help by keeping
the wiki up-to-date.  I promise to do so if I ever manage to survive
the login setup process.

Damian


On Wed, May 15, 2019 at 9:02 AM Steve Kargl
<sgk@troutmask.apl.washington.edu> wrote:
>
> On Wed, May 15, 2019 at 04:24:47PM +0300, Janne Blomqvist wrote:
> > As of Fortran 2018 it's allowed to open the same file on multiple
> > units.
> >
> > fortran/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.
> >
> > Regtested on x86_64-pc-linux-gnu, Ok for trunk?
>
> Yes.
>
> --
> Steve

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Allow opening file on multiple units
  2019-05-15 18:30   ` Damian Rouson
@ 2019-05-15 19:21     ` Janne Blomqvist
  0 siblings, 0 replies; 4+ messages in thread
From: Janne Blomqvist @ 2019-05-15 19:21 UTC (permalink / raw)
  To: Damian Rouson; +Cc: Steve Kargl, gfortran, gcc patches

On Wed, May 15, 2019 at 9:30 PM Damian Rouson
<damian@sourceryinstitute.org> wrote:
>
> Could someone please update the Fortran 2018 status page on the wiki
> to reflect this patch?

Thanks for the reminder, done.

-- 
Janne Blomqvist

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-05-15 19:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-15 13:25 [PATCH] Allow opening file on multiple units Janne Blomqvist
2019-05-15 16:02 ` Steve Kargl
2019-05-15 18:30   ` Damian Rouson
2019-05-15 19:21     ` Janne Blomqvist

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).