re PR libfortran/37753 (Convert="BIG_ENDIAN" reverses character)

2008-10-09  Thomas Koenig  <tkoenig@gcc.gnu.org>

	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  <tkoenig@gcc.gnu.org>

	PR libfortran/37753
	* gfortran.dg/convert_2.f90:  New test case.

From-SVN: r141008
This commit is contained in:
Thomas Koenig 2008-10-09 19:28:58 +00:00
parent c0451df714
commit e81897731e
4 changed files with 37 additions and 4 deletions

View File

@ -1,3 +1,8 @@
2008-10-09 Thomas Koenig <tkoenig@gcc.gnu.org>
PR libfortran/37753
* gfortran.dg/convert_2.f90: New test case.
2008-10-09 Daniel Kraft <d@domob.eu> 2008-10-09 Daniel Kraft <d@domob.eu>
PR fortran/35723 PR fortran/35723

View File

@ -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

View File

@ -1,3 +1,11 @@
2008-10-09 Thomas Koenig <tkoenig@gcc.gnu.org>
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 <jvdelisle@gcc.gnu.org 2008-10-08 Jerry DeLisle <jvdelisle@gcc.gnu.org
PR libfortran/37707 PR libfortran/37707

View File

@ -738,8 +738,8 @@ unformatted_read (st_parameter_dt *dtp, bt type,
{ {
size_t i, sz; size_t i, sz;
if (dtp->u.p.current_unit->flags.convert == GFC_CONVERT_NATIVE if (likely (dtp->u.p.current_unit->flags.convert == GFC_CONVERT_NATIVE)
|| size == 1) || kind == 1)
{ {
sz = size * nelems; sz = size * nelems;
if (type == BT_CHARACTER) if (type == BT_CHARACTER)
@ -789,8 +789,8 @@ static void
unformatted_write (st_parameter_dt *dtp, bt type, unformatted_write (st_parameter_dt *dtp, bt type,
void *source, int kind, size_t size, size_t nelems) void *source, int kind, size_t size, size_t nelems)
{ {
if (dtp->u.p.current_unit->flags.convert == GFC_CONVERT_NATIVE || if (likely (dtp->u.p.current_unit->flags.convert == GFC_CONVERT_NATIVE)
size == 1) || kind == 1)
{ {
size_t stride = type == BT_CHARACTER ? size_t stride = type == BT_CHARACTER ?
size * GFC_SIZE_OF_CHAR_KIND(kind) : size; size * GFC_SIZE_OF_CHAR_KIND(kind) : size;