[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Evaluate / fold-transfer.f90
blob833c828a62966dc45b2fe9d0d09ac05ffb6b1907
1 ! RUN: %python %S/test_folding.py %s %flang_fc1
2 ! Tests folding of TRANSFER(...)
4 module m
5 logical, parameter :: test_r2i_s_1 = transfer(1., 0) == int(z'3f800000')
6 logical, parameter :: test_r2i_v_1 = all(transfer(1., [integer::]) == [int(z'3f800000')])
7 logical, parameter :: test_r2i_v_2 = all(transfer([1., 2.], [integer::]) == [int(z'3f800000'), int(z'40000000')])
8 logical, parameter :: test_r2i_vs_1 = all(transfer([1., 2.], [integer::], 1) == [int(z'3f800000')])
10 type :: t
11 real :: x = 0.
12 end type t
13 logical, parameter :: test_t2i_s_1 = transfer(t(1.), 0) == int(z'3f800000')
14 logical, parameter :: test_t2i_v_1 = all(transfer(t(1.), [integer::]) == [int(z'3f800000')])
15 logical, parameter :: test_t2i_v_2 = all(transfer([t(1.), t(2.)], [integer::]) == [int(z'3f800000'), int(z'40000000')])
16 logical, parameter :: test_t2i_vs_1 = all(transfer([t(1.), t(2.)], [integer::], 1) == [int(z'3f800000')])
18 type(t), parameter :: t1 = transfer(1., t())
19 logical, parameter :: test_r2t_s_1 = t1%x == 1.
20 type(t), parameter :: t2(*) = transfer(1., [t::])
21 logical, parameter :: test_r2t_v_1 = all(t2%x == [1.])
22 type(t), parameter :: t3(*) = transfer([1., 2.], [t::])
23 logical, parameter :: test_r2t_v_2 = all(t3%x == [1., 2.])
24 type(t), parameter :: t4(*) = transfer([1., 2.], t(), 1)
25 logical, parameter :: test_r2t_vs_1 = all(t4%x == [1.])
27 logical, parameter :: test_nan = transfer(int(z'7ff8000000000000', 8), 0._8) /= transfer(int(z'7ff8000000000000', 8), 0._8)
29 integer, parameter :: jc1 = transfer("abcd", 0)
30 logical, parameter :: test_c2i_s_1 = jc1 == int(z'61626364') .or. jc1 == int(z'64636261')
31 integer, parameter :: jc2(*) = transfer("abcd", [integer::])
32 logical, parameter :: test_c2i_v_1 = all(jc2 == int(z'61626364') .or. jc1 == int(z'64636261'))
33 integer, parameter :: jc3(*) = transfer(["abcd", "efgh"], [integer::])
34 logical, parameter :: test_c2i_v_2 = all(jc3 == [int(z'61626364'), int(z'65666768')]) .or. all(jc3 == [int(z'64636261'), int(z'68676665')])
35 integer, parameter :: jc4(*) = transfer(["abcd", "efgh"], 0, 1)
36 logical, parameter :: test_c2i_vs_1 = all(jc4 == [int(z'61626364')]) .or. all(jc4 == [int(z'64636261')])
38 integer, parameter :: le1 = int(z'64636261', 4), be1 = int(z'65666768', 4)
39 character*5, parameter :: le1c(*) = transfer(le1, [character(5)::])
40 character*5, parameter :: be1c(*) = transfer(be1, [character(5)::])
41 logical, parameter :: test_i2c_s = all(le1c == ["abcd"//char(0)]) .or. all(be1c == ["efgh"//char(0)])
42 end module