2012-12-26 Jerry DeLisle <jvdelisle@gcc.gnu.org>
authorjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 26 Dec 2012 18:11:42 +0000 (18:11 +0000)
committerjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 26 Dec 2012 18:11:42 +0000 (18:11 +0000)
PR libfortran/48960
* io/open.c (st_parameter_open):  Assign newunit number to user
variable only if the the associated open statement is successful.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@194724 138bc75d-0d04-0410-961f-82ee72b054a4

libgfortran/ChangeLog
libgfortran/io/open.c

index debd88c..04803ec 100644 (file)
@@ -1,3 +1,9 @@
+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. 
+
 2012-12-26  Janne Blomqvist  <jb@gcc.gnu.org>
 
        PR fortran/55539
index d086d2e..c6b7303 100644 (file)
@@ -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 ();
 }