compare_spec_to_ref, despite its name, has the side effect of writing to the
array ref it is supposed to check (in the coarray case). I found this very
surprising, hence this patch which moves the relevant code to
resolve_array_ref, just after the call to compare_spec_to_ref (so that the
code path is exactly the same).
OK?
2011-09-14 Mikael Morin <[email protected]>
* resolve.c (compare_spec_to_ref): Move coarray ref initialization
code...
(resolve_array_ref): ... here.
diff --git a/resolve.c b/resolve.c
index b038402..4c991c8 100644
--- a/resolve.c
+++ b/resolve.c
@@ -4389,14 +4389,6 @@ compare_spec_to_ref (gfc_array_ref *ar)
return FAILURE;
}
- if (as->corank && ar->codimen == 0)
- {
- int n;
- ar->codimen = as->corank;
- for (n = ar->dimen; n < ar->dimen + ar->codimen; n++)
- ar->dimen_type[n] = DIMEN_THIS_IMAGE;
- }
-
return SUCCESS;
}
@@ -4665,6 +4657,14 @@ resolve_array_ref (gfc_array_ref *ar)
if (!ar->as->cray_pointee && compare_spec_to_ref (ar) == FAILURE)
return FAILURE;
+ if (ar->as->corank && ar->codimen == 0)
+ {
+ int n;
+ ar->codimen = ar->as->corank;
+ for (n = ar->dimen; n < ar->dimen + ar->codimen; n++)
+ ar->dimen_type[n] = DIMEN_THIS_IMAGE;
+ }
+
return SUCCESS;
}