5 ! Based on an example by Thomas Henlich
10 integer, dimension(:), allocatable
:: i
13 type(tx
), pointer :: x
22 class(t
), target
:: this
23 type(tx
), target
:: that
25 this
%x
=> this
%find_x(that
, .true
.)
26 if (associated (this
%x
)) call abort()
27 this
%x
=> this
%find_x(that
, .false
.)
28 if(any (this
%x
%i
/= [5, 7])) call abort()
29 if (.not
.associated (this
%x
,that
)) call abort()
31 if (associated (this
%x
,that
)) call abort()
32 if (allocated(this
%x
%i
)) call abort()
33 this
%x
= this
%find_x(that
, .false
.)
35 if(any (this
%x
%i
/= [5, 7])) call abort() ! FAILS
37 if (allocated (this
%y
%i
)) call abort()
38 this
%y
= this
%find_y() ! FAILS
39 if (.not
.allocated (this
%y
%i
)) call abort()
40 if(any (this
%y
%i
/= [6, 8])) call abort()
42 function find_x(this
, that
, l_null
)
43 class(t
), intent(in
) :: this
44 type(tx
), target
:: that
45 type(tx
), pointer :: find_x
54 function find_y(this
) result(res
)
55 class(t
), intent(in
) :: this
56 type(tx
), allocatable
:: res