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
This commit is contained in:
Francois-Xavier Coudert 2011-11-08 23:54:43 +00:00 committed by François-Xavier Coudert
parent 4408b0865b
commit b35f6a97ab
4 changed files with 30 additions and 1 deletions

View File

@ -1,3 +1,8 @@
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

View File

@ -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)

View File

@ -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>

View File

@ -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" }