re PR libfortran/33055 (Runtime error in INQUIRE unit existance with -fdefault-integer-8)
authorJerry DeLisle <jvdelisle@gcc.gnu.org>
Wed, 29 Aug 2007 02:26:01 +0000 (02:26 +0000)
committerJerry DeLisle <jvdelisle@gcc.gnu.org>
Wed, 29 Aug 2007 02:26:01 +0000 (02:26 +0000)
2007-08-28  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

PR fortran/33055
Revert previous patch.

From-SVN: r127877

gcc/fortran/trans-io.c
gcc/testsuite/gfortran.dg/negative_unit.f
gcc/testsuite/gfortran.dg/negative_unit_int8.f [deleted file]
libgfortran/io/inquire.c

index cd251086575abf4e134739af8af86d285fdfd0c2..80646cd081943a065018381b1db28e978db51da1 100644 (file)
@@ -1094,30 +1094,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;
-
-  st = gfc_get_unique_symtree (gfc_current_ns);
-  st->n.sym = gfc_new_symbol (st->name, gfc_current_ns);
-  st->n.sym->ts.type = BT_INTEGER;
-  st->n.sym->ts.kind = 4;
-  st->n.sym->attr.referenced = 1;
-  st->n.sym->refs = 1;
-  e = gfc_get_expr ();
-  e->expr_type = EXPR_VARIABLE;
-  e->symtree = st;
-  e->ts.type = BT_INTEGER;
-  e->ts.kind = 4;
-
-  return e;
-}
-
-
 /* Translate the non-IOLENGTH form of an INQUIRE statement.  */
 
 tree
@@ -1157,17 +1133,8 @@ gfc_trans_inquire (gfc_code * code)
                        p->file);
 
   if (p->exist)
-    {
-      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);
-       }
-    }
+    mask |= set_parameter_ref (&block, &post_block, var, IOPARM_inquire_exist,
+                              p->exist);
 
   if (p->opened)
     mask |= set_parameter_ref (&block, &post_block, var, IOPARM_inquire_opened,
index fcfb058672e0963020db1ca72306e4ef8fcf100b..4f942e27e988eebde377c5633f5ee8ac7646fc5e 100644 (file)
@@ -7,7 +7,6 @@
 !
 ! Bugs submitted by Walt Brainerd
       integer i
-      integer, parameter ::ERROR_BAD_UNIT = 5005
       logical l
       
       i = 0
       inquire (unit=-42, exist=l)
       if (l) call abort
 
-      i = 0 
-! This one is nasty
-      inquire (unit=2_8*huge(0_4)+20_8, exist=l, iostat=i)
-      if (l) call abort
-      if (i.ne.ERROR_BAD_UNIT) call abort
-
       end
diff --git a/gcc/testsuite/gfortran.dg/negative_unit_int8.f b/gcc/testsuite/gfortran.dg/negative_unit_int8.f
deleted file mode 100644 (file)
index 53a7daa..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-! { dg-do run }
-! { dg-options "-fdefault-integer-8" }
-! 
-! NOTE: This test is identical to negative_unit.f except -fdefault-integer-8
-!
-! PR libfortran/20660 and other bugs (not filed in bugzilla) relating
-! to negative units
-! PR 33055 Runtime error in INQUIRE unit existance with -fdefault-integer-8
-! Test case update by Jerry DeLisle <jvdelisle@gcc.gnu.org>
-!
-! Bugs submitted by Walt Brainerd
-      integer i
-      integer, parameter ::ERROR_BAD_UNIT = 5005
-      logical l
-      
-      i = 0
-! gfortran created a 'fort.-1' file and wrote "Hello" in it
-      write (unit=-1, fmt=*, iostat=i) "Hello"
-      if (i <= 0) call abort
-      
-      i = 0
-      open (unit=-11, file="xxx", iostat=i)
-      if (i <= 0) call abort
-
-      i = 0
-      inquire (unit=-42, exist=l)
-      if (l) call abort
-
-      i = 0 
-! This one is nasty
-      inquire (unit=2_8*huge(0_4)+20_8, exist=l, iostat=i)
-      if (l) call abort
-      if (i.ne.ERROR_BAD_UNIT) call abort
-
-      end
index 547b831dac47c1afd00020b75c63cdf9ac002418..b1f4a14f6c446820667c094d630d5aa2a0d478bb 100644 (file)
@@ -47,17 +47,7 @@ inquire_via_unit (st_parameter_inquire *iqp, gfc_unit * u)
   GFC_INTEGER_4 cf = iqp->common.flags;
 
   if ((cf & IOPARM_INQUIRE_HAS_EXIST) != 0)
-    {
-      *iqp->exist = (iqp->common.unit >= 0
-                    && iqp->common.unit <= GFC_INTEGER_4_HUGE);
-
-      if ((cf & IOPARM_INQUIRE_HAS_FILE) == 0)
-       {
-         if (!(*iqp->exist))
-           *iqp->common.iostat = ERROR_BAD_UNIT;
-         *iqp->exist = *iqp->exist && (*iqp->common.iostat != ERROR_BAD_UNIT);
-       }
-    }
+    *iqp->exist = iqp->common.unit >= 0;
 
   if ((cf & IOPARM_INQUIRE_HAS_OPENED) != 0)
     *iqp->opened = (u != NULL);