[Bug fortran/78737] [OOP] linking error with deferred, undefined user-defined derived-type I/O
pault at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Dec 11 22:37:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78737
--- Comment #13 from Paul Thomas <pault at gcc dot gnu.org> ---
(In reply to Paul Thomas from comment #12)
> Created attachment 40305 [details]
> Patch for the PR
>
> That attachment appears to fix the testcases of comments #6 and #9. This
> check of comment #6 runs OK:
>
> module object_interface
> type, abstract :: object
> contains
> procedure(write_formatted_interface), deferred :: write_formatted
> generic :: write(formatted) => write_formatted
> end type
> abstract interface
> subroutine write_formatted_interface(this,unit,iotype,vlist,iostat,iomsg)
> import object
> class(object), intent(in) :: this
> integer, intent(in) :: unit
> character (len=*), intent(in) :: iotype
> integer, intent(in) :: vlist(:)
> integer, intent(out) :: iostat
> character (len=*), intent(inout) :: iomsg
> end subroutine
> end interface
> type, extends(object) :: non_abstract_child
> integer :: i
> contains
> procedure :: write_formatted
> end type
> contains
> subroutine write_formatted(this,unit,iotype,vlist,iostat,iomsg)
> class(non_abstract_child), intent(in) :: this
> integer, intent(in) :: unit
> character (len=*), intent(in) :: iotype
> integer, intent(in) :: vlist(:)
> integer, intent(out) :: iostat
> character (len=*), intent(inout) :: iomsg
> select type (this)
> class is (non_abstract_child)
> print *, this%i
> class default
> print *, "Error"
> end select
> end subroutine
> subroutine assert(a)
> class(object):: a
> write(*,*) a
> end subroutine
> end module
>
> use object_interface
> class (object), allocatable :: z
> allocate (z, source = non_abstract_child (99))
> call assert (z)
> end
>
> The patch bootstraps and regtests OK. Will submit tomorrow.
>
> Paul
Sorry, should have had:
...snip...
subroutine write_formatted(this,unit,iotype,vlist,iostat,iomsg)
class(object), intent(in) :: this
...snip...
Both versions work fine.
Paul
More information about the Gcc-bugs
mailing list