1 ! { dg-do run { target i?86-*-* x86_64-*-* } }
2 ! Tests the patch to implement the array version of the TRANSFER
4 ! Contributed by Paul Thomas <pault@gcc.gnu.org>
6 character(8) :: ch(2) = (/"lmnoPQRS","LMNOpqrs"/)
8 ! tests numeric transfers(including PR testcase).
12 ! tests numeric/character transfers.
16 ! Test dummies, automatic objects and assumed character length.
18 call test3 (ch
, ch
, ch
, 8)
23 complex(4) :: z
= (1.0, 2.0)
24 real(4) :: cmp(2), a(4, 4)
25 integer(2) :: it(4, 2, 4), jt(32)
29 cmp
= transfer (z
, cmp
) * 2.0
30 if (any (cmp
.ne
. (/2.0, 4.0/))) call abort ()
32 ! Check that size smaller than the source word length is OK.
35 cmp
= transfer (z
, cmp
, 1) * 8.0
36 if (any (cmp
.ne
. (/-8.0, 4.0/))) call abort ()
38 ! Check multi-dimensional sources and that transfer works as an actual
39 ! argument of reshape.
41 a
= reshape ((/(rand (), i
= 1, 16)/), (/4,4/))
43 it
= reshape (jt
, (/4, 2, 4/))
44 if (any (reshape (transfer (it
, a
), (/4,4/)) .ne
. a
)) call abort ()
49 integer(4) :: y(4), z(2)
51 y
= (/(i
+ ishft (i
+ 1, 8) + ishft (i
+ 2, 16) &
52 + ishft (i
+ 3, 24), i
= 65, 80 , 4)/)
54 ! Check source array sections in both directions.
57 ch
= transfer (y(2:4:2), ch
)
58 if (any (ch
.ne
. (/"EFGH","MNOP","wxyz","wxyz"/))) call abort ()
60 ch
= transfer (y(4:2:-2), ch
)
61 if (any (ch
.ne
. (/"MNOP","EFGH","wxyz","wxyz"/))) call abort ()
63 ! Check that a complete array transfers with size absent.
66 if (any (ch
.ne
. (/"ABCD","EFGH","IJKL","MNOP"/))) call abort ()
68 ! Check that a character array section is OK
70 z
= transfer (ch(2:3), y
)
71 if (any (z
.ne
. y(2:3))) call abort ()
73 ! Check dest array sections in both directions.
76 ch(3:4) = transfer (y
, ch
, 2)
77 if (any (ch
.ne
. (/"wxyz","wxyz","ABCD","EFGH"/))) call abort ()
79 ch(3:2:-1) = transfer (y
, ch
, 3)
80 if (any (ch
.ne
. (/"wxyz","EFGH","ABCD","wxyz"/))) call abort ()
82 ! Check that too large a value of size is cut off.
85 ch(1:2) = transfer (y
, ch
, 3)
86 if (any (ch
.ne
. (/"ABCD","EFGH","wxyz","wxyz"/))) call abort ()
88 ! Make sure that character to numeric is OK.
91 if (any (y(1:2) .ne
. z
)) call abort ()
95 subroutine test3 (ch1
, ch2
, ch3
, clen
)
97 character(8) :: ch1(:)
98 character(*) :: ch2(2)
99 character(clen
) :: ch3(2)
100 character(8) :: cntrl(2) = (/"lmnoPQRS","LMNOpqrs"/)
102 ic
= transfer (cntrl
, ic
)
104 ! Check assumed shape.
106 if (any (ic
.ne
. transfer (ch1
, ic
))) call abort ()
108 ! Check assumed character length.
110 if (any (ic
.ne
. transfer (ch2
, ic
))) call abort ()
112 ! Check automatic character length.
114 if (any (ic
.ne
. transfer (ch3
, ic
))) call abort ()