This is for consistency. As dim == dimen-1 means "we are in the outermost loop",
we should check against the loop dimension, not the array dimension.
An assertion is added to check that it is in fact the same.
OK?
2011-10-19  Mikael Morin  <mik...@gcc.gnu.org>

        * trans-array.c (gfc_trans_preloop_setup): Use loop's dimension instead
        of array's dimention. Check that it is indeed the same.
diff --git a/trans-array.c b/trans-array.c
index f5e30ae..476978e 100644
--- a/trans-array.c
+++ b/trans-array.c
@@ -2861,13 +2861,14 @@ gfc_trans_preloop_setup (gfc_loopinfo * loop, int dim, int flag,
 
       if (dim >= info->dimen)
 	continue;
+      gcc_assert (info->dimen == loop->dimen);
 
       if (info->ref)
 	ar = &info->ref->u.ar;
       else
 	ar = NULL;
 
-      if (dim == info->dimen - 1)
+      if (dim == loop->dimen - 1)
 	i = 0;
       else
 	i = dim + 1;
@@ -2876,7 +2877,7 @@ gfc_trans_preloop_setup (gfc_loopinfo * loop, int dim, int flag,
       gcc_assert (i == loop->order[i]);
       i = loop->order[i];
 
-      if (dim == info->dimen - 1)
+      if (dim == loop->dimen - 1)
 	{
 	  stride = gfc_conv_array_stride (info->descriptor, info->dim[i]);
 

Reply via email to