re PR libfortran/51407 (Use of BOZ edit descriptors to edit real and complex data...
authorTobias Burnus <burnus@net-b.de>
Thu, 8 Dec 2011 18:54:27 +0000 (19:54 +0100)
committerTobias Burnus <burnus@gcc.gnu.org>
Thu, 8 Dec 2011 18:54:27 +0000 (19:54 +0100)
2011-12-08  Tobias Burnus  <burnus@net-b.de>

        PR fortran/51407
        * io/transfer.c (require_numeric_type): New function.
        (formatted_transfer_scalar_read, formatted_transfer_scalar_write):
        Use it, allow BOZ edit descriptors with F2008.

2011-12-08  Tobias Burnus  <burnus@net-b.de>

        PR fortran/51407
        * gfortran.dg/io_real_boz_3.f90: New.
        * gfortran.dg/io_real_boz_4.f90: New.
        * gfortran.dg/io_real_boz_5.f90: New.

From-SVN: r182132

gcc/fortran/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/io_real_boz_3.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/io_real_boz_4.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/io_real_boz_5.f90 [new file with mode: 0644]

index 727368188995df345881af450262fe979c601663..602059fce7bb1fa017b9463cf94bae649b27f3aa 100644 (file)
@@ -1,3 +1,10 @@
+2011-12-08  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/51407
+       * io/transfer.c (require_numeric_type): New function.
+       (formatted_transfer_scalar_read, formatted_transfer_scalar_write):
+       Use it, allow BOZ edit descriptors with F2008.
+
 2011-12-08  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/51448
index 66645cd984b63242b66eeb33c0b75dd6c361deb4..9eef8568cdf4ea01c73f0250cf7398011fd8ee22 100644 (file)
@@ -1,4 +1,11 @@
-2011-12-07  Tobias Burnus  <burnus@net-b.de>
+2011-12-08  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/51407
+       * gfortran.dg/io_real_boz_3.f90: New.
+       * gfortran.dg/io_real_boz_4.f90: New.
+       * gfortran.dg/io_real_boz_5.f90: New.
+
+2011-12-08  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/51448
        * gfortran.dg/realloc_on_assign_8.f90: New.
diff --git a/gcc/testsuite/gfortran.dg/io_real_boz_3.f90 b/gcc/testsuite/gfortran.dg/io_real_boz_3.f90
new file mode 100644 (file)
index 0000000..8a6f096
--- /dev/null
@@ -0,0 +1,34 @@
+! { dg-do  run }
+! { dg-options "-std=f2008" }
+!
+! PR fortran/51407
+!
+! Fortran 2008 allows BOZ edit descriptors for real/complex.
+!
+       real(kind=4) :: x
+       complex(kind=4) :: z
+       character(len=64) :: str1
+
+       x = 1.0_16 + 2.0_16**(-105)
+       z = cmplx (1.0, 2.0)
+
+       write (str1,'(b32)') x
+       read (str1,'(b32)') x
+       write (str1,'(o32)') x
+       read (str1,'(o32)') x
+       write (str1,'(z32)') x
+       read (str1,'(z32)') x
+       write (str1,'(b0)') x
+       write (str1,'(o0)') x
+       write (str1,'(z0)') x
+
+       write (str1,'(2b32)') z
+       read (str1,'(2b32)') z
+       write (str1,'(2o32)') z
+       read (str1,'(2o32)') z
+       write (str1,'(2z32)') z
+       read (str1,'(2z32)') z
+       write (str1,'(2b0)') z
+       write (str1,'(2o0)') z
+       write (str1,'(2z0)') z
+       end
diff --git a/gcc/testsuite/gfortran.dg/io_real_boz_4.f90 b/gcc/testsuite/gfortran.dg/io_real_boz_4.f90
new file mode 100644 (file)
index 0000000..b70555a
--- /dev/null
@@ -0,0 +1,15 @@
+! { dg-do  run }
+! { dg-options "-std=f2003" }
+!
+! PR fortran/51407
+!
+! Valid in F2008, but in F95/F2003:
+! { dg-output "Expected INTEGER for item 1 in formatted transfer, got REAL" }
+! { dg-shouldfail "Only F2003: BOZ edit with REAL" }
+!
+       real(kind=16) :: x
+       character(len=32) :: str1
+       x = 1.0_16 + 2.0_16**(-105)
+       write (str1,'(z32)') x
+       write (str1,'(z0)') x
+       end
diff --git a/gcc/testsuite/gfortran.dg/io_real_boz_5.f90 b/gcc/testsuite/gfortran.dg/io_real_boz_5.f90
new file mode 100644 (file)
index 0000000..6a36ee5
--- /dev/null
@@ -0,0 +1,13 @@
+! { dg-do  run }
+! { dg-options "-std=f2008" }
+!
+! PR fortran/51407
+!
+! Invalid in F2008 (accepted with -std=gnu)
+! { dg-output "Expected numeric type for item 1 in formatted transfer, got CHARACTER" }
+! { dg-shouldfail "Character type in BOZ" }
+!
+       character(len=32) :: str1
+       x = 1.0_16 + 2.0_16**(-105)
+       write (str1,'(z0)') 'X'
+       end