From: Thomas Koenig Date: Tue, 6 Aug 2024 18:14:36 +0000 (+0200) Subject: Add test case for B, Z and O descriptors. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=58cbd148ed210f33102dd04cfcb8cfb6d7d1dd76;p=thirdparty%2Fgcc.git Add test case for B, Z and O descriptors. --- diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi index f0cdbaef557c..1afd12fcf14c 100644 --- a/gcc/fortran/gfortran.texi +++ b/gcc/fortran/gfortran.texi @@ -2742,9 +2742,8 @@ used as index variables in @code{DO} loops or as array indices. Unsigned numbers have a trailing @code{u} as suffix, optionally followed by a @code{KIND} number separated by an underscore. -Input and output can be done using the @code{I} and (to be -implemented) @code{X}, @code{O} and @code{Z} descriptors, plus -unformatted I/O. +Input and output can be done using the @code{I}, @code{B}, @code{O} +and @code{Z} descriptors, plus unformatted I/O. Here is a small, somewhat contrived example of their use: @smallexample diff --git a/gcc/testsuite/gfortran.dg/unsigned_10.f90 b/gcc/testsuite/gfortran.dg/unsigned_10.f90 new file mode 100644 index 000000000000..df9167649fe4 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/unsigned_10.f90 @@ -0,0 +1,56 @@ +! { dg-do run } +! { dg-options "-funsigned" } +! Test I/O with Z, O and B descriptors. + +program main + implicit none + unsigned(kind=8) :: u,v + integer :: i + open(10,status="scratch") + u = 3u + do i=0,63 + write (10,'(Z16)') u + u = u + u + end do + rewind 10 + u = 3u + do i=0,63 + read (10,'(Z16)') v + if (u /= v) then + print *,u,v + end if + u = u + u + end do + rewind 10 + u = 3u + do i=0,63 + write (10,'(O22)') u + u = u + u + end do + rewind 10 + u = 3u + do i=0,63 + read (10,'(O22)') v + if (u /= v) then + print *,u,v + end if + u = u + u + end do + + rewind 10 + u = 3u + do i=0,63 + write (10,'(B64)') u + u = u + u + end do + rewind 10 + u = 3u + do i=0,63 + read (10,'(B64)') v + if (u /= v) then + print *,u,v + end if + u = u + u + end do + +end program main