Commit b35f6a97 by Francois-Xavier Coudert Committed by François-Xavier Coudert

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
parent 4408b086
2011-11-08 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> 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 PR fortran/50409
* expr.c (gfc_simplify_expr): Substrings can't have negative * expr.c (gfc_simplify_expr): Substrings can't have negative
length. length.
......
...@@ -2295,6 +2295,24 @@ gfc_resolve_close (gfc_close *close) ...@@ -2295,6 +2295,24 @@ gfc_resolve_close (gfc_close *close)
if (gfc_reference_st_label (close->err, ST_LABEL_TARGET) == FAILURE) if (gfc_reference_st_label (close->err, ST_LABEL_TARGET) == FAILURE)
return 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 if (close->unit->expr_type == EXPR_CONSTANT
&& close->unit->ts.type == BT_INTEGER && close->unit->ts.type == BT_INTEGER
&& mpz_sgn (close->unit->value.integer) < 0) && mpz_sgn (close->unit->value.integer) < 0)
......
2011-11-08 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> 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 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> 2011-10-23 Jason Merrill <jason@redhat.com>
......
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
close(10, iostat=u,status="keep") close(10, iostat=u,status="keep")
close(10, iostat=u,status="delete") close(10, iostat=u,status="delete")
close(10, iostat=u,status=foo) ! { dg-warning "STATUS specifier in CLOSE statement" } close(10, iostat=u,status=foo) ! { dg-warning "STATUS specifier in CLOSE statement" }
close(iostat=u) ! { dg-error "requires a UNIT number" }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment