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
)) STOP 1
27 this
%x
=> this
%find_x(that
, .false
.)
28 if(any (this
%x
%i
/= [5, 7])) STOP 2
29 if (.not
.associated (this
%x
,that
)) STOP 3
31 if (associated (this
%x
,that
)) STOP 4
32 if (allocated(this
%x
%i
)) STOP 5
33 this
%x
= this
%find_x(that
, .false
.)
35 if(any (this
%x
%i
/= [5, 7])) STOP 6 ! FAILS
37 if (allocated (this
%y
%i
)) STOP 7
38 this
%y
= this
%find_y() ! FAILS
39 if (.not
.allocated (this
%y
%i
)) STOP 8
40 if(any (this
%y
%i
/= [6, 8])) STOP 9
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