aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>2011-11-08 23:54:43 +0000
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>2011-11-08 23:54:43 +0000
commitb35f6a97ab0d40701c3545d99f45b614ce9b5553 (patch)
tree9a459cdd1fb882574e76a36ea3d2454777d3bedd
parent4408b0865b29a502144810a61296e7711e042aa5 (diff)
downloadgcc-b35f6a97ab0d40701c3545d99f45b614ce9b5553.zip
gcc-b35f6a97ab0d40701c3545d99f45b614ce9b5553.tar.gz
gcc-b35f6a97ab0d40701c3545d99f45b614ce9b5553.tar.bz2
re PR fortran/50404 (SIGSEGV in gfc_resolve_close)
PR fortran/50404 * io.c (gfc_resolve_close): CLOSE requires a UNIT. * gfortran.dg/io_constraints_3.f90: Improve testcase. From-SVN: r181183
-rw-r--r--gcc/fortran/ChangeLog5
-rw-r--r--gcc/fortran/io.c18
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/gfortran.dg/io_constraints_3.f901
4 files changed, 30 insertions, 1 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 29294f7..0d1d7b6 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,5 +1,10 @@
2011-11-08 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+ PR fortran/50404
+ * io.c (gfc_resolve_close): CLOSE requires a UNIT.
+
+2011-11-08 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+
PR fortran/50409
* expr.c (gfc_simplify_expr): Substrings can't have negative
length.
diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c
index a291bb8..88f7a249e 100644
--- a/gcc/fortran/io.c
+++ b/gcc/fortran/io.c
@@ -2295,6 +2295,24 @@ gfc_resolve_close (gfc_close *close)
if (gfc_reference_st_label (close->err, ST_LABEL_TARGET) == FAILURE)
return FAILURE;
+ if (close->unit == NULL)
+ {
+ /* Find a locus from one of the arguments to close, when UNIT is
+ not specified. */
+ locus loc = gfc_current_locus;
+ if (close->status)
+ loc = close->status->where;
+ else if (close->iostat)
+ loc = close->iostat->where;
+ else if (close->iomsg)
+ loc = close->iomsg->where;
+ else if (close->err)
+ loc = close->err->where;
+
+ gfc_error ("CLOSE statement at %L requires a UNIT number", &loc);
+ return FAILURE;
+ }
+
if (close->unit->expr_type == EXPR_CONSTANT
&& close->unit->ts.type == BT_INTEGER
&& mpz_sgn (close->unit->value.integer) < 0)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index de8cdc4..1e46164 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,7 +1,12 @@
2011-11-08 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+ PR fortran/50404
+ * gfortran.dg/io_constraints_3.f90: Improve testcase.
+
+2011-11-08 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+
PR fortran/50409
- * gcc/testsuite/gfortran.dg/string_5.f90: Improve testcase.
+ * gfortran.dg/string_5.f90: Improve testcase.
2011-10-23 Jason Merrill <jason@redhat.com>
diff --git a/gcc/testsuite/gfortran.dg/io_constraints_3.f90 b/gcc/testsuite/gfortran.dg/io_constraints_3.f90
index 7622a24..dfba53ba 100644
--- a/gcc/testsuite/gfortran.dg/io_constraints_3.f90
+++ b/gcc/testsuite/gfortran.dg/io_constraints_3.f90
@@ -66,6 +66,7 @@
close(10, iostat=u,status="keep")
close(10, iostat=u,status="delete")
close(10, iostat=u,status=foo) ! { dg-warning "STATUS specifier in CLOSE statement" }
+ close(iostat=u) ! { dg-error "requires a UNIT number" }