aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-io.c
diff options
context:
space:
mode:
authorJerry DeLisle <jvdelisle@gcc.gnu.org>2007-08-26 22:04:48 +0000
committerJerry DeLisle <jvdelisle@gcc.gnu.org>2007-08-26 22:04:48 +0000
commit128997b6a50945943c47b02ca4d743e22e4d4786 (patch)
tree179fe2796441d99ba4d1e150090496d54cca0623 /gcc/fortran/trans-io.c
parent070b797d0a7c4032bcadf58a0b29a4cc65fd5587 (diff)
downloadgcc-128997b6a50945943c47b02ca4d743e22e4d4786.zip
gcc-128997b6a50945943c47b02ca4d743e22e4d4786.tar.gz
gcc-128997b6a50945943c47b02ca4d743e22e4d4786.tar.bz2
re PR libfortran/33055 (Runtime error in INQUIRE unit existance with -fdefault-integer-8)
2007-08-26 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR fortran/33055 * trans-io.c (create_dummy_iostat): New function to create a unique dummy variable expression to use with IOSTAT. (gfc_trans_inquire): Use the new function to pass unit number error info to run-time library if a regular IOSTAT variable was not given. 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: r127817
Diffstat (limited to 'gcc/fortran/trans-io.c')
-rw-r--r--gcc/fortran/trans-io.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/gcc/fortran/trans-io.c b/gcc/fortran/trans-io.c
index 80646cd..cd25108 100644
--- a/gcc/fortran/trans-io.c
+++ b/gcc/fortran/trans-io.c
@@ -1094,6 +1094,30 @@ 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
@@ -1133,8 +1157,17 @@ gfc_trans_inquire (gfc_code * code)
p->file);
if (p->exist)
- mask |= set_parameter_ref (&block, &post_block, var, IOPARM_inquire_exist,
- 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);
+ }
+ }
if (p->opened)
mask |= set_parameter_ref (&block, &post_block, var, IOPARM_inquire_opened,