| 1 |
! { dg-do run } |
| 2 |
! { dg-shouldfail "The users message" } |
| 3 |
module sk1 |
| 4 |
implicit none |
| 5 |
type char |
| 6 |
character :: ch |
| 7 |
end type char |
| 8 |
interface read (formatted) |
| 9 |
module procedure read_formatted |
| 10 |
end interface read (formatted) |
| 11 |
contains |
| 12 |
subroutine read_formatted (dtv, unit, iotype, vlist, piostat, piomsg) |
| 13 |
class (char), intent(inout) :: dtv |
| 14 |
integer, intent(in) :: unit |
| 15 |
character (len=*), intent(in) :: iotype |
| 16 |
integer, intent(in) :: vlist(:) |
| 17 |
integer, intent(out) :: piostat |
| 18 |
character (len=*), intent(inout) :: piomsg |
| 19 |
character :: ch |
| 20 |
read (unit,fmt='(A1)', advance="no", iostat=piostat, iomsg=piomsg) ch |
| 21 |
piostat = 42 |
| 22 |
piomsg="The users message containing % and %% and %s and other stuff" |
| 23 |
dtv%ch = ch |
| 24 |
end subroutine read_formatted |
| 25 |
end module sk1 |
| 26 |
|
| 27 |
program skip1 |
| 28 |
use sk1 |
| 29 |
implicit none |
| 30 |
type (char) :: x |
| 31 |
open (10,status="scratch") |
| 32 |
write (10,'(A)') '', 'a' |
| 33 |
rewind (10) |
| 34 |
read (10,*) x |
| 35 |
write (*,'(10(A))') "Read: '",x%ch,"'" |
| 36 |
end program skip1 |
| 37 |
! { dg-output ".*(unit = 10, file = .*)" } |
| 38 |
! { dg-output "Fortran runtime error: The users message containing % and %% and %s and other stuff" } |