3 ! Test the fix for PR82375. This is the allocatable version of pdt_13.f03.
5 ! Based on contribution by Ian Chivers <ian@rhymneyconsulting.co.uk>
7 module precision_module
9 integer, parameter :: sp = selected_real_kind(6, 37)
10 integer, parameter :: dp = selected_real_kind(15, 307)
11 integer, parameter :: qp = selected_real_kind( 30, 291)
12 end module precision_module
18 integer, kind :: real_kind
19 real (kind=real_kind) :: n
20 type (link(real_kind)), allocatable :: next
25 function push_8 (self, arg) result(current)
27 type (link(real_kind=dp)), allocatable, target :: self
28 type (link(real_kind=dp)), pointer :: current
30 if (allocated (self)) then
32 do while (allocated (current%next))
33 current => current%next
36 allocate (current%next)
37 current => current%next
47 function pop_8 (self) result(res)
48 type (link(real_kind=dp)), allocatable, target :: self
49 type (link(real_kind=dp)), pointer:: current
50 type (link(real_kind=dp)), pointer :: previous
54 if (allocated (self)) then
57 do while (allocated (current%next))
59 current => current%next
62 if (.not.allocated (previous%next)) then
65 deallocate (previous%next)
71 end module link_module
77 integer, parameter :: wp = dp
78 type (link(real_kind=wp)), allocatable :: root
79 type (link(real_kind=wp)), pointer :: current
81 current => push_8 (root, 1.0_8)
82 current => push_8 (root, 2.0_8)
83 current => push_8 (root, 3.0_8)
85 if (int (pop_8 (root)) .ne. 3) call abort
86 if (int (pop_8 (root)) .ne. 2) call abort
87 if (int (pop_8 (root)) .ne. 1) call abort
88 if (int (pop_8 (root)) .ne. 0) call abort