]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
module.c (mio_array_spec): Don't read as->lower for assumed-rank arrays.
authorAlessandro Fanfarillo <fanfarillo.gcc@gmail.com>
Thu, 26 Jul 2012 08:35:55 +0000 (02:35 -0600)
committerTobias Burnus <burnus@gcc.gnu.org>
Thu, 26 Jul 2012 08:35:55 +0000 (10:35 +0200)
2012-07-26  Alessandro Fanfarillo  <fanfarillo.gcc@gmail.com>
            Tobias Burnus  <burnus@net-b.de>

        * module.c (mio_array_spec): Don't read as->lower for
        assumed-rank arrays.

Co-Authored-By: Tobias Burnus <burnus@net-b.de>
From-SVN: r189881

gcc/fortran/ChangeLog
gcc/fortran/module.c

index da86834bde42facdaf02e737567aad2f7cbbcc63..136f504bfea56799c97e093db3016c5c3489d818 100644 (file)
@@ -1,3 +1,9 @@
+2012-07-26  Alessandro Fanfarillo  <fanfarillo.gcc@gmail.com>
+           Tobias Burnus  <burnus@net-b.de>
+
+       * module.c (mio_array_spec): Don't read as->lower for
+       assumed-rank arrays.
+
 2012-07-25  Tobias Burnus  <burnus@net-b.de>
 
        * trans-types.c (gfc_real16_is_float128): Fix spelling
index a3b90885f7ccf843b7728ffdf3c4ed4f531d7414..a4ff1998036672e12617c465c8bdb2981a2219ff 100644 (file)
@@ -2359,9 +2359,15 @@ mio_array_spec (gfc_array_spec **asp)
 
   if (iomode == IO_OUTPUT)
     {
+      int rank;
+
       if (*asp == NULL)
        goto done;
       as = *asp;
+
+      /* mio_integer expects nonnegative values.  */
+      rank = as->rank > 0 ? as->rank : 0;
+      mio_integer (&rank);
     }
   else
     {
@@ -2372,20 +2378,23 @@ mio_array_spec (gfc_array_spec **asp)
        }
 
       *asp = as = gfc_get_array_spec ();
+      mio_integer (&as->rank);
     }
 
-  mio_integer (&as->rank);
   mio_integer (&as->corank);
   as->type = MIO_NAME (array_type) (as->type, array_spec_types);
 
+  if (iomode == IO_INPUT && as->type == AS_ASSUMED_RANK)
+    as->rank = -1;
   if (iomode == IO_INPUT && as->corank)
     as->cotype = (as->type == AS_DEFERRED) ? AS_DEFERRED : AS_EXPLICIT;
 
-  for (i = 0; i < as->rank + as->corank; i++)
-    {
-      mio_expr (&as->lower[i]);
-      mio_expr (&as->upper[i]);
-    }
+  if (as->rank > 0)
+    for (i = 0; i < as->rank + as->corank; i++)
+      {
+       mio_expr (&as->lower[i]);
+       mio_expr (&as->upper[i]);
+      }
 
 done:
   mio_rparen ();