aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJerry DeLisle <jvdelisle@gcc.gnu.org>2013-01-02 20:29:28 +0000
committerJerry DeLisle <jvdelisle@gcc.gnu.org>2013-01-02 20:29:28 +0000
commit3fd005a68979c83df0fc9024b98a364cb3fb32dc (patch)
treed49b92eb41c27f3d0eb9485398a3d343301b1e38 /gcc
parent6a7da30fd7edbf7f22c7fad73f5b8e1ee89839b3 (diff)
downloadgcc-3fd005a68979c83df0fc9024b98a364cb3fb32dc.zip
gcc-3fd005a68979c83df0fc9024b98a364cb3fb32dc.tar.gz
gcc-3fd005a68979c83df0fc9024b98a364cb3fb32dc.tar.bz2
re PR fortran/55818 (Reading a REAL from a file which doesn't end in a new line fails)
2013-01-02 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR fortran/55818 * gfortran.dg/eof_4.f90: New test. From-SVN: r194819
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/eof_4.f90130
2 files changed, 135 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index cbfe10f..bb2103f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2013-01-02 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ PR fortran/55818
+ * gfortran.dg/eof_4.f90: New test.
+
2013-01-02 Jakub Jelinek <jakub@redhat.com>
* lib/c-compat.exp (compat-use-alt-compiler): Remove
diff --git a/gcc/testsuite/gfortran.dg/eof_4.f90 b/gcc/testsuite/gfortran.dg/eof_4.f90
new file mode 100644
index 0000000..293c0fa
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/eof_4.f90
@@ -0,0 +1,130 @@
+! { dg-do run }
+! PR55818 Reading a REAL from a file which doesn't end in a new line fails
+! Test case from PR reporter.
+implicit none
+integer :: stat
+!integer :: var ! << works
+real :: var ! << fails
+character(len=10) :: cvar ! << fails
+complex :: cval
+logical :: lvar
+
+open(99, file="test.dat", access="stream", form="unformatted", status="new")
+write(99) "1", new_line("")
+write(99) "2", new_line("")
+write(99) "3"
+close(99)
+
+! Test character kind
+open(99, file="test.dat")
+read (99,*, iostat=stat) cvar
+if (stat /= 0 .or. cvar /= "1") call abort()
+read (99,*, iostat=stat) cvar
+if (stat /= 0 .or. cvar /= "2") call abort()
+read (99,*, iostat=stat) cvar ! << FAILS: stat /= 0
+if (stat /= 0 .or. cvar /= "3") call abort() ! << aborts here
+
+! Test real kind
+rewind(99)
+read (99,*, iostat=stat) var
+if (stat /= 0 .or. var /= 1.0) call abort()
+read (99,*, iostat=stat) var
+if (stat /= 0 .or. var /= 2.0) call abort()
+read (99,*, iostat=stat) var ! << FAILS: stat /= 0
+if (stat /= 0 .or. var /= 3.0) call abort()
+close(99, status="delete")
+
+! Test real kind with exponents
+open(99, file="test.dat", access="stream", form="unformatted", status="new")
+write(99) "1.0e3", new_line("")
+write(99) "2.0e-03", new_line("")
+write(99) "3.0e2"
+close(99)
+
+open(99, file="test.dat")
+read (99,*, iostat=stat) var
+if (stat /= 0) call abort()
+read (99,*, iostat=stat) var
+if (stat /= 0) call abort()
+read (99,*) var ! << FAILS: stat /= 0
+if (stat /= 0) call abort()
+close(99, status="delete")
+
+! Test logical kind
+open(99, file="test.dat", access="stream", form="unformatted", status="new")
+write(99) "Tru", new_line("")
+write(99) "fal", new_line("")
+write(99) "t"
+close(99)
+
+open(99, file="test.dat")
+read (99,*, iostat=stat) lvar
+if (stat /= 0 .or. (.not.lvar)) call abort()
+read (99,*, iostat=stat) lvar
+if (stat /= 0 .or. lvar) call abort()
+read (99,*) lvar ! << FAILS: stat /= 0
+if (stat /= 0 .or. (.not.lvar)) call abort()
+close(99, status="delete")
+
+! Test combinations of Inf and Nan
+open(99, file="test.dat", access="stream", form="unformatted", status="new")
+write(99) "infinity", new_line("")
+write(99) "nan", new_line("")
+write(99) "infinity"
+close(99)
+
+open(99, file="test.dat")
+read (99,*, iostat=stat) var
+if (stat /= 0) call abort()
+read (99,*, iostat=stat) var
+if (stat /= 0) call abort()
+read (99,*) var ! << FAILS: stat /= 0
+if (stat /= 0) call abort ! << aborts here
+close(99, status="delete")
+
+open(99, file="test.dat", access="stream", form="unformatted", status="new")
+write(99) "infinity", new_line("")
+write(99) "inf", new_line("")
+write(99) "nan"
+close(99)
+
+open(99, file="test.dat")
+read (99,*, iostat=stat) var
+if (stat /= 0) call abort()
+read (99,*, iostat=stat) var
+if (stat /= 0) call abort()
+read (99,*) var ! << FAILS: stat /= 0
+if (stat /= 0) call abort ! << aborts here
+close(99, status="delete")
+
+open(99, file="test.dat", access="stream", form="unformatted", status="new")
+write(99) "infinity", new_line("")
+write(99) "nan", new_line("")
+write(99) "inf"
+close(99)
+
+open(99, file="test.dat")
+read (99,*, iostat=stat) var
+if (stat /= 0) call abort()
+read (99,*, iostat=stat) var
+if (stat /= 0) call abort()
+read (99,*) var ! << FAILS: stat /= 0
+if (stat /= 0) call abort ! << aborts here
+close(99, status="delete")
+
+! Test complex kind
+open(99, file="test.dat", access="stream", form="unformatted", status="new")
+write(99) "(1,2)", new_line("")
+write(99) "(2,3)", new_line("")
+write(99) "(4,5)"
+close(99)
+
+open(99, file="test.dat")
+read (99,*, iostat=stat) cval
+if (stat /= 0 .or. cval /= cmplx(1,2)) call abort()
+read (99,*, iostat=stat) cval
+if (stat /= 0 .or. cval /= cmplx(2,3)) call abort()
+read (99,*, iostat=stat) cval ! << FAILS: stat /= 0, value is okay
+if (stat /= 0 .or. cval /= cmplx(4,5)) call abort()
+close(99, status="delete")
+end