re PR libfortran/33055 (Runtime error in INQUIRE unit existance with -fdefault-integer-8)

2007-10-15  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.

From-SVN: r129328
This commit is contained in:
Jerry DeLisle 2007-10-15 13:55:47 +00:00
parent d4731b80de
commit c16dd6a855
2 changed files with 45 additions and 2 deletions

View File

@ -1,3 +1,11 @@
2007-10-15 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.
2007-10-14 Tobias Burnus <burnus@net-b.de>
PR fortran/33745

View File

@ -1083,6 +1083,32 @@ 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);
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
@ -1122,8 +1148,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,