3 ! Check that PR91316 is fixed. Note removal of recursive I/O.
5 ! Contributed by Jose Rui Faustino de Sousa <jrfsousa@gcc.gnu.org>
7 ! NAGFOR complains correctly about the finalization of an INTENT(OUT) dummy
8 ! with an impure finalization subroutine, within a pure procedure.
9 ! It also complains about the finalization of final_set, which does not seem
10 ! to be correct (see finalize_50.f90).
11 ! Both procedures have been made impure so that this testcase runs with both
36 interface assignment(=)
37 module procedure final_init
38 end interface assignment(=)
40 integer, public
:: final_ctr
= 0
41 integer, public
:: final_res
= 0
45 impure elemental
subroutine final_init(this
, n
)
46 type(final_t
), intent(out
) :: this
47 integer, intent(in
) :: n
49 end subroutine final_init
51 impure elemental
function final_set(n
) result(this
)
52 integer, intent(in
) :: n
55 end function final_set
57 elemental
function final_get(this
) result(n
)
58 type(final_t
), intent(in
) :: this
61 end function final_get
63 subroutine final_end(this
)
64 type(final_t
), intent(inout
) :: this
65 ! print *, "DESTROY: ", this%n !< generates illegal, recursive io in 'final_s4'
67 final_ctr
= final_ctr
+ 1
69 end subroutine final_end
76 ! call final_init(f0, 0)
86 print *, "f1: ", final_get(f
)
87 if ((final_ctr
.ne
. 1) .or
. (final_res
.ne
. -1)) stop 1
88 end subroutine final_s1
92 print *, "f2: ", final_get(f
)
93 if ((final_ctr
.ne
. 3) .or
. (final_res
.ne
. -1)) stop 1
94 end subroutine final_s2
98 print *, "f3: ", final_get(f
)
99 if ((final_ctr
.ne
. 6) .or
. (final_res
.ne
. 3)) stop 1
100 end subroutine final_s3
101 subroutine final_s4()
102 print *, "f4: ", final_get(final_set(4))
103 if ((final_ctr
.ne
. 8) .or
. (final_res
.ne
. 4)) stop 1
104 end subroutine final_s4