2007-10-15 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/33055
* io/inquire.c (inquire_via_unit): If inquiring by unit, check for
an error condition from the IOSTAT variable and set EXIST to false if
there was a bad unit number.
From-SVN: r129344
+2007-10-15 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ PR libfortran/33055
+ * io/inquire.c (inquire_via_unit): If inquiring by unit, check for
+ an error condition from the IOSTAT variable and set EXIST to false if
+ there was a bad unit number.
+
2007-10-14 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/33672
GFC_INTEGER_4 cf = iqp->common.flags;
if ((cf & IOPARM_INQUIRE_HAS_EXIST) != 0)
- *iqp->exist = iqp->common.unit >= 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 = LIBERROR_BAD_UNIT;
+ *iqp->exist = *iqp->exist
+ && (*iqp->common.iostat != LIBERROR_BAD_UNIT);
+ }
+ }
if ((cf & IOPARM_INQUIRE_HAS_OPENED) != 0)
*iqp->opened = (u != NULL);