15cbf8c8b8cb1cf51eb269d5530e0933573a79b5
[platform/upstream/gcc48.git] / gcc / testsuite / gfortran.dg / mvbits_1.f90
1 ! { dg-do run }
2 ! PR 25577
3 ! MVBITS didn't work correctly for integer types wider than a C int
4 ! The testcase is based on the one Dale Ranta posted in the bug report
5 implicit none
6 integer(1) i1,j1
7 integer(2) i2,j2
8 integer(4) i4,j4
9 integer(8) i8,j8
10 integer ibits,n
11
12 ibits=bit_size(1_1)
13 do n=1,ibits
14    i1=-1
15    call mvbits(1_1, 0,n,i1,0)
16    j1=-1-2_1**n+2
17    if(i1.ne.j1)call abort
18 enddo
19 ibits=bit_size(1_2)
20 do n=1,ibits
21    i2=-1
22    call mvbits(1_2, 0,n,i2,0)
23    j2=-1-2_2**n+2
24    if(i2.ne.j2)call abort
25 enddo
26 ibits=bit_size(1_4)
27 do n=1,ibits
28    i4=-1
29    call mvbits(1_4, 0,n,i4,0)
30    j4=-1-2_4**n+2
31    if(i4.ne.j4)call abort
32 enddo
33 ibits=bit_size(1_8)
34 do n=1,ibits
35    i8=-1
36    call mvbits(1_8, 0,n,i8,0)
37    j8=-1-2_8**n+2
38    if(i8.ne.j8)call abort
39 enddo
40 end