3 ! Test the fix for PR98342.
5 ! Contributed by Martin Stein <mscfd@gmx.net>
10 public get_tuple
, sel_rank1
, sel_rank2
, sel_rank3
13 integer, dimension(:), allocatable
:: t
18 function sel_rank1(x
) result(s
)
19 character(len
=:), allocatable
:: s
20 type(tuple
), dimension(..), intent(in
) :: x
29 end function sel_rank1
31 function sel_rank2(x
) result(s
)
32 character(len
=:), allocatable
:: s
33 class(tuple
), dimension(..), intent(in
) :: x
42 end function sel_rank2
44 function sel_rank3(x
) result(s
)
45 character(len
=:), allocatable
:: s
46 class(*), dimension(..), intent(in
) :: x
55 end function sel_rank3
57 function get_tuple(t
) result(a
)
59 integer, dimension(:), intent(in
) :: t
60 allocate(a
%t
, source
=t
)
61 end function get_tuple
70 integer, dimension(1:3) :: x
71 character(len
=:), allocatable
:: output
76 ! Derived type formal arg
77 output
= sel_rank1(get_tuple (x
)) ! runtime: Error in `./alloc_rank.x':
78 if (output
.ne
. '10') stop 1
79 output
= sel_rank1([z
]) ! This worked OK
80 if (output
.ne
. '11') stop 2
83 output
= sel_rank2(get_tuple (x
)) ! runtime: Error in `./alloc_rank.x':
84 if (output
.ne
. '20') stop 3
85 output
= sel_rank2([z
]) ! This worked OK
86 if (output
.ne
. '21') stop 4
88 ! Unlimited polymorphic formal arg
89 output
= sel_rank3(get_tuple (x
)) ! runtime: Error in `./alloc_rank.x':
90 if (output
.ne
. '30') stop 5
91 output
= sel_rank3([z
]) ! runtime: segmentation fault
92 if (output
.ne
. '31') stop 6
96 end program alloc_rank