2 ! Tests the fix for PR59414, comment #3, in which the allocate
3 ! expressions were not correctly being stripped to provide the
4 ! vpointer as an lhs to the pointer assignment of the vptr from
5 ! the SOURCE expression.
7 ! Contributed by Antony Lewis <antony@cosmologist.info>
16 type Object_array_pointer
17 class(t
), pointer :: p(:)
22 subroutine AddArray1 (P
, Pt
)
24 class(Object_array_pointer
) :: Pt
27 class
is (Object_array_pointer
)
28 if (associated (Pt
%P
)) deallocate (Pt
%P
)
29 allocate(Pt
%P(1:SIZE(P
)), source
=P
)
33 subroutine AddArray2 (P
, Pt
)
35 class(Object_array_pointer
) :: Pt
38 type is (Object_array_pointer
)
39 if (associated (Pt
%P
)) deallocate (Pt
%P
)
40 allocate(Pt
%P(1:SIZE(P
)), source
=P
)
44 subroutine AddArray3 (P
, Pt
)
46 class(Object_array_pointer
) :: Pt
49 class
is (Object_array_pointer
)
50 if (associated (Pt
%P
)) deallocate (Pt
%P
)
51 allocate(Pt
%P(1:4), source
=P
)
55 subroutine AddArray4 (P
, Pt
)
57 class(Object_array_pointer
) :: Pt
60 class
is (Object_array_pointer
)
61 if (associated (Pt
%P
)) deallocate (Pt
%P
)
62 allocate(Pt
%P(1:SIZE(P
)), source
=P
)
68 type(Object_array_pointer
), pointer :: Pt
69 class(t
), pointer :: P(:)
71 allocate (P(2), source
= [t(1),t(2)])
72 allocate (Pt
, source
= Object_array_pointer(NULL()))
73 call AddArray1 (P
, Pt
)
74 select
type (x
=> Pt
%p
)
76 if (any (x
%i
.ne
. [1,2])) STOP 1
81 allocate (P(3), source
= [t(3),t(4),t(5)])
82 allocate (Pt
, source
= Object_array_pointer(NULL()))
83 call AddArray2 (P
, Pt
)
84 select
type (x
=> Pt
%p
)
86 if (any (x
%i
.ne
. [3,4,5])) STOP 2
91 allocate (Pt
, source
= Object_array_pointer(NULL()))
92 call AddArray3 (t(6), Pt
)
93 select
type (x
=> Pt
%p
)
95 if (any (x
%i
.ne
. [6,6,6,6])) STOP 3
99 allocate (Pt
, source
= Object_array_pointer(NULL()))
100 call AddArray4 ([t(7), t(8)], Pt
)
101 select
type (x
=> Pt
%p
)
103 if (any (x
%i
.ne
. [7,8])) STOP 4