From: Jerry DeLisle Date: Wed, 26 Dec 2012 18:11:42 +0000 (+0000) Subject: re PR libfortran/48960 (OPEN statement modifies NEWUNIT variable on error) X-Git-Tag: releases/gcc-4.8.0~1242 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4e766b5d405a628b974daa96e92d36fd6fd92870;p=thirdparty%2Fgcc.git re PR libfortran/48960 (OPEN statement modifies NEWUNIT variable on error) 2012-12-26 Jerry DeLisle 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 --- diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index debd88c8f4f6..04803ec28d61 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,9 @@ +2012-12-26 Jerry DeLisle + + PR libfortran/48960 + * io/open.c (st_parameter_open): Assign newunit number to user + variable only if the the associated open statement is successful. + 2012-12-26 Janne Blomqvist PR fortran/55539 diff --git a/libgfortran/io/open.c b/libgfortran/io/open.c index d086d2edfef9..c6b73033e864 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 (); }