OSDN Git Service

2009-09-12 Jerry DeLisle <jvdelisle@gcc.gnu.org>
authorjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 13 Sep 2009 03:44:34 +0000 (03:44 +0000)
committerjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 13 Sep 2009 03:44:34 +0000 (03:44 +0000)
PR libgfortran/41328
* gfortran.dg/cr_lf.f90: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151666 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/cr_lf.f90 [new file with mode: 0644]

index 2a0705a..cc1b26b 100644 (file)
@@ -1,3 +1,8 @@
+2009-09-12  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+
+       PR libgfortran/41328
+       * gfortran.dg/cr_lf.f90: New test.
+
 2009-09-11  Michael Matz  <matz@suse.de>
 
        PR middle-end/41275
diff --git a/gcc/testsuite/gfortran.dg/cr_lf.f90 b/gcc/testsuite/gfortran.dg/cr_lf.f90
new file mode 100644 (file)
index 0000000..855e703
--- /dev/null
@@ -0,0 +1,36 @@
+! { dg-do run }
+! { dg-options "-fbackslash" }
+! PR41328 and PR41168 Improper read of CR-LF sequences.
+! Test case prepared by Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+program main
+   implicit none
+   integer :: iostat, n_chars_read
+   character(len=1) :: buffer(64) = ""
+   open( unit=10, form="formatted", access="stream", status="scratch")
+   write(10, fmt="(a)", advance="no") "a\rb\rc\r"
+   rewind(10)
+   
+   read( unit=10, fmt='(64A)', advance='NO', iostat=iostat,          &
+         size=n_chars_read ) buffer
+   if (n_chars_read.ne.1) call abort
+   if (any(buffer(1:n_chars_read).ne."a")) call abort
+   if (.not.is_iostat_eor(iostat)) call abort
+
+   read( unit=10, fmt='(64A)', advance='NO', iostat=iostat,          &
+         size=n_chars_read ) buffer
+   if (n_chars_read.ne.1) call abort
+   if (any(buffer(1:n_chars_read).ne."b")) call abort
+   if (.not.is_iostat_eor(iostat)) call abort
+
+   read( unit=10, fmt='(64A)', advance='NO', iostat=iostat,          &
+         size=n_chars_read ) buffer
+   if (n_chars_read.ne.1) call abort
+   if (any(buffer(1:n_chars_read).ne."c")) call abort
+   if (.not.is_iostat_eor(iostat)) call abort
+
+   read( unit=10, fmt='(64A)', advance='NO', iostat=iostat,          &
+         size=n_chars_read ) buffer
+   if (n_chars_read.ne.0) call abort
+   if (any(buffer(1:n_chars_read).ne."a")) call abort
+   if (.not.is_iostat_end(iostat)) call abort
+end program main