+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
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");
}
-/* 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
{
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)