diff mbox

[fortran,01..04/14] Support coarray subreferences: Add subreferences support in gfc_conv_expr_descriptor

Message ID 20111007143750.3558.83173@gimli.local
State New
Headers show

Commit Message

Mikael Morin Oct. 7, 2011, 2:38 p.m. UTC
These patches change the descriptor initialization code in
gfc_conv_expr_descriptor introduced by the recent scalarizer patchset at
http://gcc.gnu.org/ml/fortran/2011-09/msg00056.html.
It was supposing (just like the code it was replacing) that coarrays were
always full, but a subobject of a coarray is also a coarray (if non-allocatable, non-pointer).
Thus, if `a' is a coarray of rank 2; `a', `a(1,:)' and `a(1,2)' are all valid
coarrays.
Because of the two latter ones, we have to distinguish between the full array
rank (2 in the three cases above), and the partial reference rank (respectively
2, 1, 0).
As a result:
 - in patch 4, we use loop.dimen (partial rank) instead of ndim (full rank) for
   accessing loop and descriptor elements.
 - in patch 3, we count codimensions from 0 and add to it either ndim or
   loop.dimen depending on whether we access array ref's elements or loop
   elements.
Patches 1 and 2 are preliminary changes.

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

	* trans-array.c (gfc_conv_expr_descriptor): Move ndim initialization
	earlier.
2011-10-06  Mikael Morin  <mikael.morin@sfr.fr>

	* trans-array.c (gfc_conv_expr_descriptor): Save some horizontal space.
2011-10-06  Mikael Morin  <mikael.morin@sfr.fr>

	PR fortran/50420
	* trans-array.c (gfc_conv_expr_descriptor): Count codimensions starting
	from zero, and add then the relevant offset (either ndim or loop.dimen)
	depending on context.
2011-10-06  Mikael Morin  <mikael.morin@sfr.fr>

	PR fortran/50420
	* trans-array.c (gfc_conv_expr_descriptor): Use loop.dimen instead of
	ndim for the descriptor's rank.
diff mbox

Patch

diff --git a/trans-array.c b/trans-array.c
index 57534e0..605b356 100644
--- a/trans-array.c
+++ b/trans-array.c
@@ -6138,13 +6138,13 @@  gfc_conv_expr_descriptor (gfc_se * se, gfc_expr * expr, gfc_ss * ss)
 					  gfc_rank_cst[dim], stride);
 	}
 
-      for (n = ndim; n < ndim + codim; n++)
+      for (n = loop.dimen; n < loop.dimen + codim; n++)
 	{
 	  from = loop.from[n];
 	  to = loop.to[n];
 	  gfc_conv_descriptor_lbound_set (&loop.pre, parm,
 					  gfc_rank_cst[n], from);
-	  if (n < ndim + codim - 1)
+	  if (n < loop.dimen + codim - 1)
 	    gfc_conv_descriptor_ubound_set (&loop.pre, parm,
 					    gfc_rank_cst[n], to);
 	}