diff options
author | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2012-12-26 18:11:42 +0000 |
---|---|---|
committer | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2012-12-26 18:11:42 +0000 |
commit | 4e766b5d405a628b974daa96e92d36fd6fd92870 (patch) | |
tree | 0886bfa4650216361f9a44a4e9855fdb8fc0364b /libgfortran/io/open.c | |
parent | b4b575ce7854f4a49de8de93f38b7639e01b040b (diff) | |
download | gcc-4e766b5d405a628b974daa96e92d36fd6fd92870.zip gcc-4e766b5d405a628b974daa96e92d36fd6fd92870.tar.gz gcc-4e766b5d405a628b974daa96e92d36fd6fd92870.tar.bz2 |
re PR libfortran/48960 (OPEN statement modifies NEWUNIT variable on error)
2012-12-26 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/48960
* io/open.c (st_parameter_open): Assign newunit number to user
variable only if the the associated open statement is successful.
From-SVN: r194724
Diffstat (limited to 'libgfortran/io/open.c')
-rw-r--r-- | libgfortran/io/open.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/libgfortran/io/open.c b/libgfortran/io/open.c index d086d2e..c6b7303 100644 --- a/libgfortran/io/open.c +++ b/libgfortran/io/open.c @@ -844,10 +844,7 @@ st_open (st_parameter_open *opp) if ((opp->common.flags & IOPARM_LIBRETURN_MASK) == IOPARM_LIBRETURN_OK) { if ((opp->common.flags & IOPARM_OPEN_HAS_NEWUNIT)) - { - *opp->newunit = get_unique_unit_number(opp); - opp->common.unit = *opp->newunit; - } + opp->common.unit = get_unique_unit_number(opp); u = find_or_create_unit (opp->common.unit); if (u->s == NULL) @@ -859,6 +856,10 @@ st_open (st_parameter_open *opp) else already_open (opp, u, &flags); } - + + if ((opp->common.flags & IOPARM_OPEN_HAS_NEWUNIT) + && (opp->common.flags & IOPARM_LIBRETURN_MASK) == IOPARM_LIBRETURN_OK) + *opp->newunit = opp->common.unit; + library_end (); } |