re PR fortran/61933 (Inquire on internal units)

2015-01-14  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/61933
	* io.c (gfc_match_inquire): Generate error if unit number in
	inquire statement is a constant -1.  All other values allowed.
	* trans-io.c (gfc_trans_inquire): Delete dummy iostat variable.
	(create_dummy_iostat): Delete function no longer used.

From-SVN: r219630
This commit is contained in:
Jerry DeLisle 2015-01-15 03:51:16 +00:00
parent d5d9c650a2
commit 2da229cb17
3 changed files with 16 additions and 34 deletions

View File

@ -1,3 +1,11 @@
2015-01-14 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/61933
* io.c (gfc_match_inquire): Generate error if unit number in
inquire statement is a constant -1. All other values allowed.
* trans-io.c (gfc_trans_inquire): Delete dummy iostat variable.
(create_dummy_iostat): Delete function no longer used.
2015-01-13 Jakub Jelinek <jakub@redhat.com>
PR fortran/64528

View File

@ -3998,6 +3998,14 @@ gfc_match_inquire (void)
goto cleanup;
}
if (inquire->unit != NULL && inquire->unit->expr_type == EXPR_CONSTANT
&& inquire->unit->ts.type == BT_INTEGER
&& mpz_get_si (inquire->unit->value.integer) == -1)
{
gfc_error ("UNIT number in INQUIRE statement at %L can not be -1", &loc);
goto cleanup;
}
if (gfc_pure (NULL))
{
gfc_error ("INQUIRE statement not allowed in PURE procedure at %C");

View File

@ -1186,33 +1186,6 @@ gfc_trans_flush (gfc_code * code)
}
/* Create a dummy iostat variable to catch any error due to bad unit. */
static gfc_expr *
create_dummy_iostat (void)
{
gfc_symtree *st;
gfc_expr *e;
gfc_get_ha_sym_tree ("@iostat", &st);
st->n.sym->ts.type = BT_INTEGER;
st->n.sym->ts.kind = gfc_default_integer_kind;
gfc_set_sym_referenced (st->n.sym);
gfc_commit_symbol (st->n.sym);
st->n.sym->backend_decl
= gfc_create_var (gfc_get_int_type (st->n.sym->ts.kind),
st->n.sym->name);
e = gfc_get_expr ();
e->expr_type = EXPR_VARIABLE;
e->symtree = st;
e->ts.type = BT_INTEGER;
e->ts.kind = st->n.sym->ts.kind;
return e;
}
/* Translate the non-IOLENGTH form of an INQUIRE statement. */
tree
@ -1255,13 +1228,6 @@ gfc_trans_inquire (gfc_code * code)
{
mask |= set_parameter_ref (&block, &post_block, var, IOPARM_inquire_exist,
p->exist);
if (p->unit && !p->iostat)
{
p->iostat = create_dummy_iostat ();
mask |= set_parameter_ref (&block, &post_block, var,
IOPARM_common_iostat, p->iostat);
}
}
if (p->opened)