c: Fix up pointer types to may_alias structures [PR114493]
[official-gcc.git] / gcc / testsuite / gfortran.dg / merge_bits_1.F90
blob92589a619f82e66487277d7739ec8dd53a320cf7
1 ! Test the MERGE_BITS intrinsic
3 ! { dg-do run }
4 ! { dg-options "-ffree-line-length-none" }
6   interface run_merge
7     procedure run_merge_1
8     procedure run_merge_2
9     procedure run_merge_4
10     procedure run_merge_8
11   end interface
13 #define CHECK(I,J,K) \
14   if (merge_bits(I,J,K) /= ior(iand(I,K),iand(J,not(K)))) STOP 1; \
15   if (run_merge(I,J,K) /= merge_bits(I,J,K)) STOP 2
17   CHECK(13_1,18_1,22_1)
18   CHECK(-13_1,18_1,22_1)
19   CHECK(13_1,-18_1,22_1)
20   CHECK(13_1,18_1,-22_1)
22   CHECK(13_2,18_2,22_2)
23   CHECK(-13_2,18_2,22_2)
24   CHECK(13_2,-18_2,22_2)
25   CHECK(13_2,18_2,-22_2)
27   CHECK(13_4,18_4,22_4)
28   CHECK(-13_4,18_4,22_4)
29   CHECK(13_4,-18_4,22_4)
30   CHECK(13_4,18_4,-22_4)
32   CHECK(13_8,18_8,22_8)
33   CHECK(-13_8,18_8,22_8)
34   CHECK(13_8,-18_8,22_8)
35   CHECK(13_8,18_8,-22_8)
37 contains
39   function run_merge_1 (i, j, k) result(res)
40     integer(kind=1) :: i, j, k, res
41     res = merge_bits(i,j,k)
42   end function 
43   function run_merge_2 (i, j, k) result(res)
44     integer(kind=2) :: i, j, k, res
45     res = merge_bits(i,j,k)
46   end function 
47   function run_merge_4 (i, j, k) result(res)
48     integer(kind=4) :: i, j, k, res
49     res = merge_bits(i,j,k)
50   end function 
51   function run_merge_8 (i, j, k) result(res)
52     integer(kind=8) :: i, j, k, res
53     res = merge_bits(i,j,k)
54   end function 
55 end