]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/52724 (Internal read with character(kind=4) data)
authorThomas Koenig <tkoenig@gcc.gnu.org>
Sat, 29 Sep 2012 17:38:46 +0000 (17:38 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Sat, 29 Sep 2012 17:38:46 +0000 (17:38 +0000)
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

gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/internal_readwrite_3.f90 [new file with mode: 0644]
libgfortran/ChangeLog
libgfortran/io/list_read.c
libgfortran/io/unix.c

index 4a5af28a7658c05831ff59ec5b1f9d8fcf5cd7a5..502ffdc511e584eb32022c3edc49ee65332d37ee 100644 (file)
@@ -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 (file)
index 0000000..279fac5
--- /dev/null
@@ -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
index f8a68d74171a7be4093f733e5685e1a067bac2fd..feeb10a41462f5fd068e16a87a096de59f619fce 100644 (file)
@@ -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.
index 9d301d6241894104381e036e525aa5e02f5b289c..403e7190a1234ed5f010c534f0258821cd0a9e55 100644 (file)
@@ -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);
index 1a9faea486e6c4507ba9d35821c75208eec6d491..805d4bbd205f906825e9ceb83d2b6374bc855636 100644 (file)
@@ -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;