| 1 |
! { dg-do run } |
| 2 |
! { dg-options "-fdec" } |
| 3 |
! |
| 4 |
! Runtime tests to verify logical-to-bitwise operations perform as expected |
| 5 |
! with -fdec. |
| 6 |
! |
| 7 |
|
| 8 |
subroutine assert(expected, actual, str) |
| 9 |
implicit none |
| 10 |
character(*), intent(in) :: str |
| 11 |
integer, intent(in) :: expected, actual |
| 12 |
if (actual .ne. expected) then |
| 13 |
write (*, '(A,I4,I4)') str, expected, actual |
| 14 |
STOP 1 |
| 15 |
endif |
| 16 |
end subroutine |
| 17 |
|
| 18 |
implicit none |
| 19 |
|
| 20 |
integer expected, expected_expr |
| 21 |
integer output_vars, output_const, output_expr |
| 22 |
integer op1, op2, mult |
| 23 |
|
| 24 |
mult = 3 |
| 25 |
op1 = 3 |
| 26 |
op2 = 5 |
| 27 |
|
| 28 |
!!!! AND -> IAND |
| 29 |
|
| 30 |
expected = IAND(op1, op2) |
| 31 |
expected_expr = mult*expected |
| 32 |
|
| 33 |
output_const = 3 .AND. 5 |
| 34 |
output_vars = op1 .AND. op2 |
| 35 |
output_expr = mult * (op1 .AND. op2) |
| 36 |
|
| 37 |
call assert(expected, output_vars, "( ) and") |
| 38 |
call assert(expected, output_const, "(c) and") |
| 39 |
call assert(expected_expr, output_expr, "(x) and") |
| 40 |
|
| 41 |
!!!! EQV -> NOT IEOR |
| 42 |
|
| 43 |
expected = NOT(IEOR(op1, op2)) |
| 44 |
expected_expr = mult*expected |
| 45 |
|
| 46 |
output_const = 3 .EQV. 5 |
| 47 |
output_vars = op1 .EQV. op2 |
| 48 |
output_expr = mult * (op1 .EQV. op2) |
| 49 |
|
| 50 |
call assert(expected, output_vars, "( ) EQV") |
| 51 |
call assert(expected, output_const, "(c) EQV") |
| 52 |
call assert(expected_expr, output_expr, "(x) EQV") |
| 53 |
|
| 54 |
!!!! NEQV -> IEOR |
| 55 |
|
| 56 |
expected = IEOR(op1, op2) |
| 57 |
expected_expr = mult*expected |
| 58 |
|
| 59 |
output_const = 3 .NEQV. 5 |
| 60 |
output_vars = op1 .NEQV. op2 |
| 61 |
output_expr = mult * (op1 .NEQV. op2) |
| 62 |
|
| 63 |
call assert(expected, output_vars, "( ) NEQV") |
| 64 |
call assert(expected, output_const, "(c) NEQV") |
| 65 |
call assert(expected_expr, output_expr, "(x) NEQV") |
| 66 |
|
| 67 |
!!!! NOT -> NOT |
| 68 |
|
| 69 |
expected = NOT(op2) |
| 70 |
expected_expr = mult*expected |
| 71 |
|
| 72 |
output_const = .NOT. 5 |
| 73 |
output_vars = .NOT. op2 |
| 74 |
output_expr = mult * (.NOT. op2) |
| 75 |
|
| 76 |
call assert(expected, output_vars, "( ) NOT") |
| 77 |
call assert(expected, output_const, "(c) NOT") |
| 78 |
call assert(expected_expr, output_expr, "(x) NOT") |
| 79 |
|
| 80 |
!!!! OR -> IOR |
| 81 |
|
| 82 |
expected = IOR(op1, op2) |
| 83 |
expected_expr = mult*expected |
| 84 |
|
| 85 |
output_const = 3 .OR. 5 |
| 86 |
output_vars = op1 .OR. op2 |
| 87 |
output_expr = mult * (op1 .OR. op2) |
| 88 |
|
| 89 |
call assert(expected, output_vars, "( ) OR") |
| 90 |
call assert(expected, output_const, "(c) OR") |
| 91 |
call assert(expected_expr, output_expr, "(x) OR") |
| 92 |
|
| 93 |
!!!! XOR -> IEOR, not to be confused with .XOR. |
| 94 |
|
| 95 |
expected = IEOR(op1, op2) |
| 96 |
expected_expr = mult*expected |
| 97 |
|
| 98 |
output_const = 3 .XOR. 5 |
| 99 |
output_vars = op1 .XOR. op2 |
| 100 |
output_expr = mult * (op1 .XOR. op2) |
| 101 |
|
| 102 |
call assert(expected, output_vars, "( ) XOR") |
| 103 |
call assert(expected, output_const, "(c) XOR") |
| 104 |
call assert(expected_expr, output_expr, "(x) XOR") |
| 105 |
|
| 106 |
end |