blob: bee9acbd6b592c17313a917798e5081af5ce3dcc [file] [log] [blame]
! { dg-do compile }
! Test fix for the original in PR793822 and for PR80156.
! Contributed by Walt Brainerd <>
! and (PR80156) <>
module dollar_mod
implicit none
type, public :: dollar_type
real :: amount
procedure :: Write_dollar
generic :: write(formatted) => Write_dollar
end type dollar_type
PRIVATE :: write (formatted) ! This used to ICE
subroutine Write_dollar &
(dollar_value, unit, b_edit_descriptor, v_list, iostat, iomsg)
class (dollar_type), intent(in) :: dollar_value
integer, intent(in) :: unit
character (len=*), intent(in) :: b_edit_descriptor
integer, dimension(:), intent(in) :: v_list
integer, intent(out) :: iostat
character (len=*), intent(inout) :: iomsg
write (unit=unit, fmt="(f9.2)", iostat=iostat) dollar_value%amount
end subroutine Write_dollar
end module dollar_mod
module pr80156
implicit none
type, public :: String
character(len=:), allocatable :: raw
end type
public :: write(unformatted) ! Gave an error due to the first fix for PR79382.
interface write(unformatted)
module procedure writeUnformatted
end interface
subroutine writeUnformatted(self, unit, iostat, iomsg)
class(String) , intent(in) :: self
integer , intent(in) :: unit
integer , intent(out) :: iostat
character(len=*), intent(inout) :: iomsg
if (allocated(self%raw)) then
write (unit, iostat=iostat, iomsg=iomsg) self%raw
write (unit, iostat=iostat, iomsg=iomsg) ''
end subroutine
end module
use dollar_mod
type(dollar_type) :: money
money = dollar_type(50.0)
print '(DT)', money ! Make sure that the typebound generic is accessible.