Debian Codegraph @

gcc/testsuite/gfortran.dg/transfer_class_5.f90

raw
1 ! { dg-do run }
2 ! PR fortran/121263 - fix TRANSFER with rank 1 unlimited polymorhpic
3 !
4 ! Based on original testcase by Chris Cox.
5
6 module stdlib_hashmap_wrappers
7 implicit none
8 contains
9 subroutine set_rank_one_key_int( key, value )
10 integer, allocatable, intent(inout) :: key(:)
11 class(*), intent(in) :: value(:)
12 key = transfer( value, key )
13 end subroutine
14
15 subroutine set_rank_one_key_cx ( key, value )
16 complex, allocatable, intent(inout) :: key(:)
17 class(*), intent(in) :: value(:)
18 key = transfer( value, key )
19 end subroutine
20
21 subroutine set_first_key_int ( key, value )
22 integer, intent(inout) :: key
23 class(*), intent(in) :: value(:)
24 key = transfer( value(1), key )
25 end subroutine
26 end module
27
28 program p
29 use stdlib_hashmap_wrappers
30 implicit none
31 integer, allocatable :: a(:), b(:)
32 complex, allocatable :: c(:), d(:)
33 class(*),allocatable :: z(:)
34 integer :: m
35 a = [1, 2, 3, 4, 5]
36 c = cmplx (a, -a)
37 call set_rank_one_key_int (b, a)
38 call set_rank_one_key_cx (d, c)
39 call set_first_key_int (m, a)
40 ! print *, b
41 ! print *, d
42 if (size (a) /= size (b)) stop 1
43 if (any (a /= b)) stop 2
44 if (size (c) /= size (d)) stop 3
45 if (any (c /= d)) stop 4
46 if (m /= 1) stop 5
47 deallocate (d)
48 z = c
49 d = transfer (z, d)
50 if (size (c) /= size (d)) stop 6
51 if (any (c /= d)) stop 7
52 deallocate (a, b, c, d, z)
53 end program p