From e81897731e2232b88f735bf8b8ce319d76983b51 Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Thu, 9 Oct 2008 19:28:58 +0000 Subject: [PATCH] re PR libfortran/37753 (Convert="BIG_ENDIAN" reverses character) 2008-10-09 Thomas Koenig PR libfortran/37753 * io/transfer.c (unformatted_read): CONVERT_NATIVE is the usual case. Check for kind==1 for non-byte-reversing operation. (unformatted_write): Likewise. 2008-10-09 Thomas Koenig PR libfortran/37753 * gfortran.dg/convert_2.f90: New test case. From-SVN: r141008 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/convert_2.f90 | 20 ++++++++++++++++++++ libgfortran/ChangeLog | 8 ++++++++ libgfortran/io/transfer.c | 8 ++++---- 4 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/convert_2.f90 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2e61e8ca8a4..6d931c6af47 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-10-09 Thomas Koenig + + PR libfortran/37753 + * gfortran.dg/convert_2.f90: New test case. + 2008-10-09 Daniel Kraft PR fortran/35723 diff --git a/gcc/testsuite/gfortran.dg/convert_2.f90 b/gcc/testsuite/gfortran.dg/convert_2.f90 new file mode 100644 index 00000000000..9f90606885a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/convert_2.f90 @@ -0,0 +1,20 @@ +! { dg-do run } +! Check for correct ordering of character variables with CONVERT + +program main + implicit none + integer, parameter :: two_swap = 2**25 + integer(kind=4) i,j + character(len=2) :: c,d + open(20,file="convert.dat",form="unformatted",convert="swap") ! { dg-warning "CONVERT" } + write (20) "ab" + close (20) + open(20,file="convert.dat",form="unformatted",access="stream") + read(20) i,c,j + if (i .ne. two_swap .or. j .ne. two_swap .or. c .ne. "ab") call abort + close (20) + open(20,file="convert.dat",form="unformatted",convert="swap") ! { dg-warning "CONVERT" } + read (20) d + close (20,status="delete") + if (d .ne. "ab") call abort +end program main diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 7905b4cc764..8332fea3522 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,11 @@ +2008-10-09 Thomas Koenig + + PR libfortran/37753 + * io/transfer.c (unformatted_read): CONVERT_NATIVE + is the usual case. Check for kind==1 for non-byte-reversing + operation. + (unformatted_write): Likewise. + 2008-10-08 Jerry DeLisle u.p.current_unit->flags.convert == GFC_CONVERT_NATIVE - || size == 1) + if (likely (dtp->u.p.current_unit->flags.convert == GFC_CONVERT_NATIVE) + || kind == 1) { sz = size * nelems; if (type == BT_CHARACTER) @@ -789,8 +789,8 @@ static void unformatted_write (st_parameter_dt *dtp, bt type, void *source, int kind, size_t size, size_t nelems) { - if (dtp->u.p.current_unit->flags.convert == GFC_CONVERT_NATIVE || - size == 1) + if (likely (dtp->u.p.current_unit->flags.convert == GFC_CONVERT_NATIVE) + || kind == 1) { size_t stride = type == BT_CHARACTER ? size * GFC_SIZE_OF_CHAR_KIND(kind) : size;