2 ! PR78881 test for correct end of record condition and ignoring advance=
4 use, intrinsic :: iso_fortran_env, only : iostat_end, iostat_eor, output_unit
7 character(len=:), allocatable :: m_s
9 procedure, pass(this) :: read_t
10 generic :: read(formatted) => read_t
13 subroutine read_t(this, lun, iotype, vlist, istat, imsg)
14 class(t), intent(inout) :: this
15 integer, intent(in) :: lun
16 character(len=*), intent(in) :: iotype
17 integer, intent(in) :: vlist(:)
18 integer, intent(out) :: istat
19 character(len=*), intent(inout) :: imsg
25 read( unit=lun, fmt='(a1)', iostat=istat, iomsg=imsg) c
28 if (i.eq.1 .and. c.ne.'h') exit loop_read
29 !write( output_unit, fmt=sfmt) "i = ", i, ", c = ", c
31 !write( output_unit, fmt=sfmt) "i = ", i, ", istat = iostat_end"
34 !write( output_unit, fmt=sfmt) "i = ", i, ", istat = iostat_eor"
37 !write( output_unit, fmt=sfmt) "i = ", i, ", istat = ", istat
40 if (i.gt.10) exit loop_read
49 character(len=:), allocatable :: s
51 character(len=256) :: imsg
54 open(10, status="scratch")
55 write(10,'(a)') 'hello'
57 read(unit=10, fmt='(dt)', iostat=istat, iomsg=imsg) foo
58 if (imsg.ne."End of record") call abort
60 read(unit=10, fmt=*, iostat=istat, iomsg=imsg) foo
61 if (imsg.ne."End of record") call abort
63 read( unit=s, fmt='(dt)', iostat=istat, iomsg=imsg) foo
64 if (imsg.ne."End of record") call abort
65 read( unit=s, fmt=*, iostat=istat, iomsg=imsg) foo
66 if (imsg.ne."End of record") call abort
69 ! { dg-final { cleanup-modules "t_m" } }