From 2da229cb17e3fd65fdd12e9180d855ba583e1632 Mon Sep 17 00:00:00 2001 From: Jerry DeLisle Date: Thu, 15 Jan 2015 03:51:16 +0000 Subject: [PATCH] re PR fortran/61933 (Inquire on internal units) 2015-01-14 Jerry DeLisle 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 --- gcc/fortran/ChangeLog | 8 ++++++++ gcc/fortran/io.c | 8 ++++++++ gcc/fortran/trans-io.c | 34 ---------------------------------- 3 files changed, 16 insertions(+), 34 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 09fa7576488..c7080b90343 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2015-01-14 Jerry DeLisle + + 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 PR fortran/64528 diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c index 2bc80f30b7d..a03984ca607 100644 --- a/gcc/fortran/io.c +++ b/gcc/fortran/io.c @@ -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"); diff --git a/gcc/fortran/trans-io.c b/gcc/fortran/trans-io.c index ef37fcfc5c6..e619acb5ace 100644 --- a/gcc/fortran/trans-io.c +++ b/gcc/fortran/trans-io.c @@ -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) -- 2.30.2