1! { dg-do compile }
2! { dg-options "-fno-whole-file" }
3!
4! PR fortran/42051
5! PR fortran/44064
6! Access to freed symbols
7!
8! Testcase provided by Damian Rouson <damian@rouson.net>,
9! reduced by Janus Weil <janus@gcc.gnu.org>.
10
11module grid_module
12  implicit none 
13  type grid
14  end type
15  type field
16    type(grid) :: mesh
17  end type
18contains
19  real function return_x(this)
20    class(grid) :: this
21  end function
22end module 
23
24module field_module
25  use grid_module, only: field,return_x
26  implicit none 
27contains
28  subroutine output(this)
29    class(field) :: this
30    print *,return_x(this%mesh)
31  end subroutine
32end module
33
34end
35