Merge from mainline (163495:164578).
[official-gcc/graphite-test-results.git] / gcc / testsuite / gfortran.dg / masklr_2.F90
bloba7545a1881c92960dca85ca964111c5e3737ed16
1 ! Test the MASKL and MASKR intrinsics.
3 ! { dg-do run }
4 ! { dg-options "-ffree-line-length-none" }
5 ! { dg-require-effective-target fortran_integer_16 }
7 #define CHECK(I,KIND,FUNCL,FUNCR,RESL,RESR) \
8   if (maskl(I,KIND) /= RESL) call abort ; \
9   if (FUNCL(I) /= RESL) call abort ; \
10   if (maskr(I,KIND) /= RESR) call abort ; \
11   if (FUNCR(I) /= RESR) call abort
13   CHECK(0,16,run_maskl16,run_maskr16,0_16,0_16)
14   CHECK(1,16,run_maskl16,run_maskr16,-huge(0_16)-1_16,1_16)
15   CHECK(2,16,run_maskl16,run_maskr16,(-huge(0_16)-1_16)/2_16,3_16)
16   CHECK(3,16,run_maskl16,run_maskr16,(-huge(0_16)-1_16)/4_16,7_16)
17   CHECK(int(bit_size(0_16))-2,16,run_maskl16,run_maskr16,-4_16,huge(0_16)/2_16)
18   CHECK(int(bit_size(0_16))-1,16,run_maskl16,run_maskr16,-2_16,huge(0_16))
19   CHECK(int(bit_size(0_16)),16,run_maskl16,run_maskr16,-1_16,-1_16)
21 contains
23   pure integer(kind=16) function run_maskl16(i) result(res)
24     integer, intent(in) :: i
25     res = maskl(i,kind=16)
26   end function
27   pure integer(kind=16) function run_maskr16(i) result(res)
28     integer, intent(in) :: i
29     res = maskr(i,kind=16)
30   end function
32 end