re PR libfortran/18710 (img part of complex number not written to direct access file)

libgfortran/
PR fortran/18710
* io/transfer.c (unformatted_read, unformatted_write): width of
a COMPLEX is twice its kind.

gcc/testsuite/
PR fortran/18170
* gfortran.dg/direct_io_3.f90: New test.

From-SVN: r91656
This commit is contained in:
Tobias Schlüter 2004-12-02 20:39:15 +01:00 committed by Tobias Schlüter
parent 0396df8ac4
commit abd7fea9f9
4 changed files with 46 additions and 3 deletions

View File

@ -1,3 +1,8 @@
2004-12-02 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/18170
* gfortran.dg/direct_io_3.f90: New test.
2004-12-02 Nathan Sidwell <nathan@codesourcery.com>
PR 18758

View File

@ -0,0 +1,20 @@
! { dg-do run }
! PR 18710 : We used to not read and write the imaginary part of
! complex numbers
COMPLEX C, D
DOUBLE COMPLEX E, F
OPEN(UNIT=9,FILE='PR18710',ACCESS='DIRECT',RECL=132)
C = (120.0,240.0)
WRITE(9,REC=1)C
READ(9,REC=1)D
if (c /= d) call abort()
E = (120.0,240.0)
WRITE(9,REC=1)E
READ(9,REC=1)F
if (E /= F) call abort()
CLOSE(UNIT=9,STATUS='DELETE')
END

View File

@ -1,3 +1,9 @@
2004-12-02 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/18710
* io/transfer.c (unformatted_read, unformatted_write): width of
a COMPLEX is twice its kind.
2004-12-02 Richard Sandiford <rsandifo@redhat.com>
* configure.ac: Use TL_AC_GCC_VERSION to set gcc_version.

View File

@ -271,6 +271,13 @@ unformatted_read (bt type, void *dest, int length)
{
void *source;
int w;
/* Transfer functions get passed the kind of the entity, so we have
to fix this for COMPLEX data which are twice the size of their
kind. */
if (type == BT_COMPLEX)
length *= 2;
w = length;
source = read_block (&w);
@ -288,6 +295,11 @@ static void
unformatted_write (bt type, void *source, int length)
{
void *dest;
/* Correction for kind vs. length as in unformatted_read. */
if (type == BT_COMPLEX)
length *= 2;
dest = write_block (length);
if (dest != NULL)
memcpy (dest, source, length);