| Submitter | Tobias Burnus |
|---|---|
| Date | July 25, 2012, 9:23 p.m. |
| Message ID | <501063E8.3040601@net-b.de> |
| Download | mbox | patch |
| Permalink | /patch/173282/ |
| State | New |
| Headers | show |
Comments
On 25/07/2012 23:23, Tobias Burnus wrote: > 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? > Hello, I assume this sits on top of the previous patch? Then OK for both. Mikael.
Patch
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;