| 1 |
! { dg-do run } |
| 2 |
! |
| 3 |
! Test the fix for PR107872, where an ICE occurred in |
| 4 |
! resolve.cc(derived_inaccessible) because derived types with |
| 5 |
! recursive allocatable components were not catered for. |
| 6 |
! |
| 7 |
module mod1 |
| 8 |
type t |
| 9 |
integer :: data |
| 10 |
type(t), allocatable :: next |
| 11 |
contains |
| 12 |
procedure, private :: write_t |
| 13 |
generic :: write(formatted) => write_t |
| 14 |
end type |
| 15 |
contains |
| 16 |
recursive subroutine write_t(this, unit, iotype, v_list, iostat, iomsg) |
| 17 |
class(t), intent(in) :: this |
| 18 |
integer, intent(in) :: unit |
| 19 |
character(*), intent(in) :: iotype |
| 20 |
integer, intent(in) :: v_list(:) |
| 21 |
integer, intent(out) :: iostat |
| 22 |
character(*), intent(inout) :: iomsg |
| 23 |
if (ALLOCATED(this%next)) & |
| 24 |
write (unit, '(dt)') this%next |
| 25 |
write (unit, '(i2)') this%data |
| 26 |
end subroutine |
| 27 |
end module |
| 28 |
|
| 29 |
use mod1 |
| 30 |
type(t) :: a |
| 31 |
character (8) :: buffer |
| 32 |
a%data = 1 |
| 33 |
allocate (a%next) |
| 34 |
a%next%data = 2 |
| 35 |
allocate (a%next%next) |
| 36 |
a%next%next%data = 3 |
| 37 |
write (buffer, '(dt)')a |
| 38 |
deallocate (a%next) |
| 39 |
if (trim (buffer) .ne. ' 3 2 1') stop 1 |
| 40 |
end |