-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Labels
Description
Consider the following reducer:
module m
type base
character(3) :: c
contains
procedure, pass :: write
end type
type, extends(base) :: child
integer(4) :: i
end type
interface write(formatted)
subroutine writeformatted(dtv, unit, iotype, v_list, iostat, iomsg )
import base
class(base), intent(in) :: dtv
integer, intent(in) :: unit
character(*), intent(in) :: iotype
integer, intent(in) :: v_list(:)
integer, intent(out) :: iostat
character(*), intent(inout) :: iomsg
end subroutine
end interface
integer :: unit = 1
integer :: stat
character(200) :: msg
contains
class(base) function write(dtv)
class(base), intent(in) :: dtv
allocatable :: write
namelist /W/ write
allocate ( write, source = dtv )
write (unit, W, iostat = stat, iomsg = msg )
end function
end module
program funcRetrn001a
use m
class(base), allocatable :: b1
type(child) :: c1 = child ('FTN',123)
open (1, file = 'funcRetrn001a.1', form='formatted', access='sequential' )
b1 = c1%write() !! The passed-object is of type Child.
end program
subroutine writeformatted (dtv, unit, iotype, v_list, iostat, iomsg)
use m, only: base,child
class(base), intent(in) :: dtv
integer, intent(in) :: unit
character(*), intent(in) :: iotype
integer, intent(in) :: v_list(:)
integer, intent(out) :: iostat
character(*), intent(inout) :: iomsg
select type (dtv)
type is (base)
print*, "base"
type is (child)
print*, "child"
end select
end subroutine
Flang outputs base
, while the expected output is child
(both gfortran and XLF).
The type of the passed-object of c1%write()
call should be child
instead of base
.