summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.fortran-torture/compile/transfer-1.f90
blob: 9fa4bfc34cb3376944ff3f72379e5c65fa46d85d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
! Bigendian test posted by Perseus in comp.lang.fortran on 4 July 2005.
   integer(1), parameter :: zero = 0
   LOGICAL, PARAMETER :: bigend = IACHAR(TRANSFER(1,"a")) == zero
   LOGICAL :: bigendian
   call foo ()
contains
   subroutine foo ()
   integer :: chr, ans
   if (bigend) then
     ans = 1
   else
     ans = 0
   end if
   chr = IACHAR(TRANSFER(1,"a"))
   bigendian =  chr == 0_4
   if (bigendian) then
     ans = 1
   else
     ans = 0
   end if
   end subroutine foo
end