1! { dg-do compile }
2! { dg-options "-fcheck=all" }
3!
4! PR fortran/57542
5!
6! Contributed by Salvatore Filippone
7!
8module type_mod
9  type inner
10  end type inner
11
12  type outer
13    class(inner), allocatable :: item
14  end type outer
15
16  type container
17    class(outer), allocatable :: item
18  end type container
19
20  type maintype
21    type(container), allocatable :: v(:)
22  end type maintype
23
24end module type_mod
25
26subroutine testfinal(var)
27  use type_mod
28  type(maintype), intent(inout) :: var
29  ! A real code would obviously check
30  ! this is really allocated
31  deallocate(var%v(1)%item%item)
32end subroutine testfinal
33