simplify_cobound, when it looks for the coarray reference, in the AR_ELEMENT
case, first checks that it is the last reference in the chain. 
As it is what we are trying to avoid, this patch removes that and uses the
corank field directly.

OK?
2011-10-06  Mikael Morin  <mikael.mo...@sfr.fr>

        PR fortran/50420
        * simplify.c (simplify_cobound): Accept non-last-in-ref-chain coarrays.
        Don't set already set array ref.
diff --git a/simplify.c b/simplify.c
index 13a9c51..63689bb 100644
--- a/simplify.c
+++ b/simplify.c
@@ -3512,11 +3512,9 @@ simplify_cobound (gfc_expr *array, gfc_expr *dim, gfc_expr *kind, int upper)
 	  switch (ref->u.ar.type)
 	    {
 	    case AR_ELEMENT:
-	      if (ref->next == NULL)
+	      if (ref->u.ar.as->corank > 0)
 		{
-		  gcc_assert (ref->u.ar.as->corank > 0
-			      && ref->u.ar.as->rank == 0);
-		  as = ref->u.ar.as;
+		  gcc_assert (as == ref->u.ar.as);
 		  goto done;
 		}
 	      as = NULL;

Reply via email to