2015-01-14 Jerry DeLisle <jvdelisle@gcc.gnu.org>
authorjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 15 Jan 2015 03:51:16 +0000 (03:51 +0000)
committerjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 15 Jan 2015 03:51:16 +0000 (03:51 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@219630 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/io.c
gcc/fortran/trans-io.c

index 09fa757..c7080b9 100644 (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
index 2bc80f3..a03984c 100644 (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");
index ef37fcf..e619acb 100644 (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)