This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, fortran] [14/21] Remove coarray support in the scalarizer: Fix full array dimension type


This prevents a regression.
The problem is in the full array case, ar->dimen is not set at resolution time.
As a result, the code seting ar->dimen_type to DIMEN_THIS_IMAGE (see patch 2)
sets codimensions' types starting at index 0 (as if it was a scalar coarray).
Later, gfc_walk_variable_expr sets ar->dimen and the associated ar->dimen_type,
overwriting the DIMEN_THIS_IMAGE from resolve_array_ref.
There is code in gfc_walk_variable_expr which sets ar->dimen_type
to DIMEN_RANGE for codimensions too, so there is no bug until we remove that 
code (patch 18).
After patch 18, some codimensions can have dimen_type unset, more exactly set
to 0, which is not an enum valid value, and everything breaks from there.

This patch copies the code present in gfc_walk_variable expr
to set dimension types for full array references. Then we can overwrite
array dimen_type part as much as we want, the coarray dimen_type part
will be left untouched (and properly set).

The duplicate code in gfc_walk_variable_expr can't be removed, as it seems that
some array references are not passed through resolve_array_ref (I didn't
investigate further).

OK?

Attachment: no_coarray_in_scalarizer-14.CL
Description: Text document

diff --git a/resolve.c b/resolve.c
index 4c991c8..c594ebf 100644
--- a/resolve.c
+++ b/resolve.c
@@ -4637,8 +4637,23 @@ resolve_array_ref (gfc_array_ref *ar)
 	}
     }
 
-  if (ar->type == AR_FULL && ar->as->rank == 0)
-    ar->type = AR_ELEMENT;
+  if (ar->type == AR_FULL)
+    {
+      if (ar->as->rank == 0)
+	ar->type = AR_ELEMENT;
+
+      /* Make sure array is the same as array(:,:), this way
+	 we don't need to special case all the time.  */
+      ar->dimen = ar->as->rank;
+      for (i = 0; i < ar->dimen; i++)
+	{
+	  ar->dimen_type[i] = DIMEN_RANGE;
+
+	  gcc_assert (ar->start[i] == NULL);
+	  gcc_assert (ar->end[i] == NULL);
+	  gcc_assert (ar->stride[i] == NULL);
+	}
+    }
 
   /* If the reference type is unknown, figure out what kind it is.  */
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]