Merge from mainline (163495:164578).
[official-gcc/graphite-test-results.git] / gcc / testsuite / gfortran.dg / bit_comparison_2.F90
blob73d0679d08896c8ba74ab9363ac3a4130a0b20cd
1 ! Test the BGE, BGT, BLE and BLT intrinsics.
3 ! { dg-do run }
4 ! { dg-options "-ffree-line-length-none" }
5 ! { dg-require-effective-target fortran_integer_16 }
7 #define CHECK(I,J,RES) \
8   if (bge(I,J) .neqv. RES) call abort ; \
9   if (run_bge(I,J) .neqv. RES) call abort ; \
10   if (bgt(I,J) .neqv. (RES .and. (I/=J))) call abort ; \
11   if (run_bgt(I,J) .neqv. (RES .and. (I/=J))) call abort ; \
12   if (ble(J,I) .neqv. RES) call abort ; \
13   if (run_ble(J,I) .neqv. RES) call abort ; \
14   if (blt(J,I) .neqv. (RES .and. (I/=J))) call abort ; \
15   if (run_blt(J,I) .neqv. (RES .and. (I/=J))) call abort
17 #define T .true.
18 #define F .false.
20   CHECK(0_16, 0_16, T)
21   CHECK(1_16, 0_16, T)
22   CHECK(0_16, 107_16, F)
23   CHECK(5_16, huge(0_16) / 2_16, F)
24   CHECK(5_16, huge(0_16), F)
25   CHECK(-1_16, 0_16, T)
26   CHECK(0_16, -19_16, F)
27   CHECK(huge(0_16), -19_16, F)
29 contains
31   pure logical function run_bge (i, j) result(res)
32     integer(kind=16), intent(in) :: i, j
33     res = bge(i,j)
34   end function
35   pure logical function run_bgt (i, j) result(res)
36     integer(kind=16), intent(in) :: i, j
37     res = bgt(i,j)
38   end function
39   pure logical function run_ble (i, j) result(res)
40     integer(kind=16), intent(in) :: i, j
41     res = ble(i,j)
42   end function
43   pure logical function run_blt (i, j) result(res)
44     integer(kind=16), intent(in) :: i, j
45     res = blt(i,j)
46   end function
48 end