]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add test case for B, Z and O descriptors.
authorThomas Koenig <tkoenig@gcc.gnu.org>
Tue, 6 Aug 2024 18:14:36 +0000 (20:14 +0200)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Tue, 6 Aug 2024 18:14:36 +0000 (20:14 +0200)
gcc/fortran/gfortran.texi
gcc/testsuite/gfortran.dg/unsigned_10.f90 [new file with mode: 0644]

index f0cdbaef557c328997d006743b47774e980312b4..1afd12fcf14c72adbc5355b797f84a750154d336 100644 (file)
@@ -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 (file)
index 0000000..df91676
--- /dev/null
@@ -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