aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2012-09-29 17:38:46 +0000
committerThomas Koenig <tkoenig@gcc.gnu.org>2012-09-29 17:38:46 +0000
commit7c0de7535345f7d271c89d5121c7edfabd1e79f7 (patch)
treeee47c83148e108305938eb2264d383e28dae885d
parentdf98376a391d42fa570b557391199b041abaeb42 (diff)
downloadgcc-7c0de7535345f7d271c89d5121c7edfabd1e79f7.zip
gcc-7c0de7535345f7d271c89d5121c7edfabd1e79f7.tar.gz
gcc-7c0de7535345f7d271c89d5121c7edfabd1e79f7.tar.bz2
re PR fortran/52724 (Internal read with character(kind=4) data)
2012-09-29 Thomas König <tkoenig@gcc.gnu.org> PR fortran/52724 * list_read.c (next_char): Handle kind=4 characters. * unix.c (open_internal4): Correct lenth of internal file. 2012-09-29 Thomas König <tkoenig@gcc.gnu.org> PR fortran/52724 * gfortran.dg/internal_readwrite_3.f90: New test. From-SVN: r191854
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/internal_readwrite_3.f9011
-rw-r--r--libgfortran/ChangeLog6
-rw-r--r--libgfortran/io/list_read.c13
-rw-r--r--libgfortran/io/unix.c2
5 files changed, 33 insertions, 4 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4a5af28..502ffdc 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-09-29 Thomas König <tkoenig@gcc.gnu.org>
+
+ PR fortran/52724
+ * gfortran.dg/internal_readwrite_3.f90: New test.
+
2012-09-28 Dodji Seketeli <dodji@redhat.com>
* g++.dg/warn/Wunused-local-typedefs-3.C: Move the c++-only test
diff --git a/gcc/testsuite/gfortran.dg/internal_readwrite_3.f90 b/gcc/testsuite/gfortran.dg/internal_readwrite_3.f90
new file mode 100644
index 0000000..279fac5
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/internal_readwrite_3.f90
@@ -0,0 +1,11 @@
+! { dg-do run }
+! PR 52724 - this used to generate a "Bad integer" error.
+program main
+ implicit none
+ integer :: i
+ character(len=100,kind=4) :: buffer, a
+ buffer = 4_"123"
+ read(buffer,*) i
+ write (a,'(I3)') i
+ if (a /= 4_"123") call abort
+end program main
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index f8a68d7..feeb10a 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,9 @@
+2012-09-29 Thomas König <tkoenig@gcc.gnu.org>
+
+ PR fortran/52724
+ * list_read.c (next_char): Handle kind=4 characters.
+ * unix.c (open_internal4): Correct lenth of internal file.
+
2012-09-14 David Edelsohn <dje.gcc@gmail.com>
* configure: Regenerated.
diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c
index 9d301d6..403e719 100644
--- a/libgfortran/io/list_read.c
+++ b/libgfortran/io/list_read.c
@@ -199,9 +199,16 @@ next_char (st_parameter_dt *dtp)
if (is_internal_unit (dtp))
{
- char cc;
- length = sread (dtp->u.p.current_unit->s, &cc, 1);
- c = cc;
+ /* Check for kind=4 internal unit. */
+ if (dtp->common.unit)
+ length = sread (dtp->u.p.current_unit->s, &c, sizeof (gfc_char4_t));
+ else
+ {
+ char cc;
+ length = sread (dtp->u.p.current_unit->s, &cc, 1);
+ c = cc;
+ }
+
if (length < 0)
{
generate_error (&dtp->common, LIBERROR_OS, NULL);
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index 1a9faea..805d4bb 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -959,7 +959,7 @@ open_internal4 (char *base, int length, gfc_offset offset)
s->buffer = base;
s->buffer_offset = offset;
- s->active = s->file_length = length;
+ s->active = s->file_length = length * sizeof (gfc_char4_t);
s->st.vptr = &mem4_vtable;