This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, Fortran] Fix module I/O with assumed-rank arrays
- From: Tobias Burnus <burnus at net-b dot de>
- To: gfortran <fortran at gcc dot gnu dot org>, gcc patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 25 Jul 2012 23:23:52 +0200
- Subject: Re: [Patch, Fortran] Fix module I/O with assumed-rank arrays
- References: <50105221.5060702@net-b.de>
Tobias Burnus wrote:
The following issue was found by Alessandro. (It got triggered by a
larger test case, which is required for a larger patch by Alessandro,
which is not yet finished.)
Accessing the "lower[-1]" is probably not the best idea â
Build on x86-64-linux.
OK for the trunk?
I attached the wrong version â the additional problem was that
mio_integer expects nonnegative numbers.
Build and tested on x86-64-linux.
OK?
Tobias
2012-07-25 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.
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c
index 51b7059..a4ff199 100644
--- a/gcc/fortran/module.c
+++ b/gcc/fortran/module.c
@@ -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,12 +2378,14 @@ 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;