aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJerry DeLisle <jvdelisle@gcc.gnu.org>2019-01-14 00:22:00 +0000
committerJerry DeLisle <jvdelisle@gcc.gnu.org>2019-01-14 00:22:00 +0000
commit9c5f89006fa4b64c77997f660554a12315f4ac1d (patch)
treef238d50e7438578fcb6c31df6f1ab0ff3285495b /gcc
parentbff1a7315da774562db589a19a96ea522b47b900 (diff)
downloadgcc-9c5f89006fa4b64c77997f660554a12315f4ac1d.zip
gcc-9c5f89006fa4b64c77997f660554a12315f4ac1d.tar.gz
gcc-9c5f89006fa4b64c77997f660554a12315f4ac1d.tar.bz2
re PR libfortran/88776 (Namelist read from stdin: loss of data)
2019-01-13 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libfortran/88776 * io/open.c (newunit): Free format buffer if the unit specified is for stdin, stdout, or stderr. * gfortran.dg/namelist_96.f90: New test. From-SVN: r267910
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/namelist_96.f9038
2 files changed, 43 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 33a7f95..d0611e3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-01-13 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ PR libfortran/88776
+ * gfortran.dg/namelist_96.f90: New test.
+
2019-01-13 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/59345
diff --git a/gcc/testsuite/gfortran.dg/namelist_96.f90 b/gcc/testsuite/gfortran.dg/namelist_96.f90
new file mode 100644
index 0000000..5606e1f
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/namelist_96.f90
@@ -0,0 +1,38 @@
+! ( dg-do run }
+program pr88776
+ implicit none
+ character(*), parameter :: file = "pr88776.dat"
+ type t_chan
+ integer :: ichan = -1
+ character(len=8) :: flag = ''
+ integer :: band = -1
+ end type t_chan
+ type(t_chan) :: chan
+ namelist /NML/ chan
+ open (11,file=file)
+ write(11,'(a)') trim("&nml chan = 1 '#1 ' 10 /")
+ write(11,'(a)') trim("&nml chan = 2 '#2 ' 42.36/")
+ write(11,'(a)') trim("&nml chan = 3 '#3 ' 30 /")
+ close(11)
+ call read (unit=10) ! No problem
+ call read (unit=5) ! problem, now fixed
+ open (11,file=file)
+ close (11, status="delete")
+contains
+ subroutine read (unit)
+ integer, intent(in) :: unit
+ integer :: stat
+ open (unit, file=file, action="read")
+ chan = t_chan(-1,'',-1)
+ stat = 0
+ read (unit, nml=NML, iostat=stat)
+ if (stat /= 0) stop 1
+ chan = t_chan(-1,'',-1)
+ read (unit, nml=NML, iostat=stat)
+ if (stat == 0) stop 2
+ if (chan% ichan /= 2) then
+ stop 3
+ end if
+ close (unit)
+ end subroutine read
+end program pr88776