3 ! Test the fix for PR67444 in which the finalization of a polymorphic 'var'
4 ! was not being finalized before assignment. (STOP 3)
6 ! Contributed by Balint Aradi <baladi@gmail.com>
17 procedure
:: assignBasic
18 generic
:: assignment(=) => assignBasic
19 final
:: destructBasic
22 module procedure initBasic
25 function initBasic(initValue
) result(this
)
26 integer, intent(in
) :: initValue
30 end function initBasic
31 subroutine assignBasic(this
, other
)
32 class(Basic
), intent(out
) :: this
33 type(Basic
), intent(in
) :: other
34 this
%ii
= other
%ii
+ 1
36 end subroutine assignBasic
37 subroutine destructBasic(this
)
38 type(Basic
), intent(inout
) :: this
42 if (this
%ii
/= -1) stop 1 ! First finalization before assignment to 'var'
43 if (icall
/= 1) stop 2 ! and before evaluation of 'expr'.
45 if (this
%ii
/= ivalue
) stop 3 ! Finalization of intent(out) in 'assignBasic'
46 if (icall
/= 42) stop 4 ! and after evaluation of 'expr'.
48 if (this
%ii
/= ivalue
+ 1) stop 5 ! Finalization of 'expr' (function!) after assignment.
50 stop 6 ! Too many or no finalizations
52 end subroutine destructBasic
63 end subroutine useBasic
70 if (fvalue
/= 3) stop 7 ! 3 finalizations mandated.