aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2024-08-06 20:14:36 +0200
committerThomas Koenig <tkoenig@gcc.gnu.org>2024-08-06 20:14:36 +0200
commit58cbd148ed210f33102dd04cfcb8cfb6d7d1dd76 (patch)
tree9bd95a40571b7696eba5e617e22a07017fad0b09 /gcc
parent95f108c0d6ee83f20481d780d622168bd20e8585 (diff)
downloadgcc-58cbd148ed210f33102dd04cfcb8cfb6d7d1dd76.zip
gcc-58cbd148ed210f33102dd04cfcb8cfb6d7d1dd76.tar.gz
gcc-58cbd148ed210f33102dd04cfcb8cfb6d7d1dd76.tar.bz2
Add test case for B, Z and O descriptors.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/gfortran.texi5
-rw-r--r--gcc/testsuite/gfortran.dg/unsigned_10.f9056
2 files changed, 58 insertions, 3 deletions
diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi
index f0cdbae..1afd12f 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 0000000..df91676
--- /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