2 ! { dg-options "-fdec" }
4 ! Runtime tests to verify bitwise ops perform appropriate conversions
8 subroutine assert(expected
, actual
, str
)
10 character(*), intent(in
) :: str
11 integer, intent(in
) :: expected
, actual(9)
14 if (expected
.ne
. actual(i
)) then
15 write (*, '(A,I8,I8)') str
, expected
, actual(i
)
23 logical(1), volatile :: op1_1l
24 integer(1), volatile :: op1_1
, op2_1
26 logical(2), volatile :: op1_2l
27 integer(2), volatile :: op1_2
, op2_2
29 logical(4), volatile :: op1_4l
30 integer(4), volatile :: op1_4
, op2_4
32 integer, volatile :: expect
, outs(9)
45 !!! Explicit integer operands
47 expect
= IAND(op1_1
, op2_1
)
48 outs(1) = op1_1
.AND
. op2_1
49 outs(2) = op1_1
.AND
. op2_2
50 outs(3) = op1_1
.AND
. op2_4
51 outs(4) = op1_2
.AND
. op2_1
52 outs(5) = op1_2
.AND
. op2_2
53 outs(6) = op1_2
.AND
. op2_4
54 outs(7) = op1_4
.AND
. op2_1
55 outs(8) = op1_4
.AND
. op2_2
56 outs(9) = op1_4
.AND
. op2_4
57 call assert(expect
, outs
, "AND")
59 expect
= IOR(op1_1
, op2_1
)
60 outs(1) = op1_1
.OR
. op2_1
61 outs(2) = op1_1
.OR
. op2_2
62 outs(3) = op1_1
.OR
. op2_4
63 outs(4) = op1_2
.OR
. op2_1
64 outs(5) = op1_2
.OR
. op2_2
65 outs(6) = op1_2
.OR
. op2_4
66 outs(7) = op1_4
.OR
. op2_1
67 outs(8) = op1_4
.OR
. op2_2
68 outs(9) = op1_4
.OR
. op2_4
70 call assert(expect
, outs
, "OR")
72 expect
= NOT(IEOR(op1_1
, op2_1
))
73 outs(1) = op1_1
.EQV
. op2_1
74 outs(2) = op1_1
.EQV
. op2_2
75 outs(3) = op1_1
.EQV
. op2_4
76 outs(4) = op1_2
.EQV
. op2_1
77 outs(5) = op1_2
.EQV
. op2_2
78 outs(6) = op1_2
.EQV
. op2_4
79 outs(7) = op1_4
.EQV
. op2_1
80 outs(8) = op1_4
.EQV
. op2_2
81 outs(9) = op1_4
.EQV
. op2_4
83 call assert(expect
, outs
, "EQV")
85 expect
= IEOR(op1_1
, op2_1
)
86 outs(1) = op1_1
.NEQV
. op2_1
87 outs(2) = op1_1
.NEQV
. op2_2
88 outs(3) = op1_1
.NEQV
. op2_4
89 outs(4) = op1_2
.NEQV
. op2_1
90 outs(5) = op1_2
.NEQV
. op2_2
91 outs(6) = op1_2
.NEQV
. op2_4
92 outs(7) = op1_4
.NEQV
. op2_1
93 outs(8) = op1_4
.NEQV
. op2_2
94 outs(9) = op1_4
.NEQV
. op2_4
96 call assert(expect
, outs
, "NEQV")
98 !!! Logical -> Integer operand conversions
103 expect
= IAND(op1_1
, op2_1
)
104 outs(1) = op1_1l
.AND
. op2_1
! implicit conversions
105 outs(2) = op1_1l
.AND
. op2_2
106 outs(3) = op1_1l
.AND
. op2_4
107 outs(4) = op1_2l
.AND
. op2_1
108 outs(5) = op1_2l
.AND
. op2_2
109 outs(6) = op1_2l
.AND
. op2_4
110 outs(7) = op1_4l
.AND
. op2_1
111 outs(8) = op1_4l
.AND
. op2_2
112 outs(9) = op1_4l
.AND
. op2_4
113 call assert(expect
, outs
, "AND")
115 expect
= IOR(op1_1
, op2_1
)
116 outs(1) = op1_1l
.OR
. op2_1
! implicit conversions
117 outs(2) = op1_1l
.OR
. op2_2
118 outs(3) = op1_1l
.OR
. op2_4
119 outs(4) = op1_2l
.OR
. op2_1
120 outs(5) = op1_2l
.OR
. op2_2
121 outs(6) = op1_2l
.OR
. op2_4
122 outs(7) = op1_4l
.OR
. op2_1
123 outs(8) = op1_4l
.OR
. op2_2
124 outs(9) = op1_4l
.OR
. op2_4
126 call assert(expect
, outs
, "OR")
128 expect
= NOT(IEOR(op1_1
, op2_1
))
129 outs(1) = op1_1l
.EQV
. op2_1
! implicit conversions
130 outs(2) = op1_1l
.EQV
. op2_2
131 outs(3) = op1_1l
.EQV
. op2_4
132 outs(4) = op1_2l
.EQV
. op2_1
133 outs(5) = op1_2l
.EQV
. op2_2
134 outs(6) = op1_2l
.EQV
. op2_4
135 outs(7) = op1_4l
.EQV
. op2_1
136 outs(8) = op1_4l
.EQV
. op2_2
137 outs(9) = op1_4l
.EQV
. op2_4
139 call assert(expect
, outs
, "EQV")
141 expect
= IEOR(op1_1
, op2_1
)
142 outs(1) = op1_1l
.NEQV
. op2_1
! implicit conversions
143 outs(2) = op1_1l
.NEQV
. op2_2
144 outs(3) = op1_1l
.NEQV
. op2_4
145 outs(4) = op1_2l
.NEQV
. op2_1
146 outs(5) = op1_2l
.NEQV
. op2_2
147 outs(6) = op1_2l
.NEQV
. op2_4
148 outs(7) = op1_4l
.NEQV
. op2_1
149 outs(8) = op1_4l
.NEQV
. op2_2
150 outs(9) = op1_4l
.NEQV
. op2_4
152 call assert(expect
, outs
, "NEQV")