We can't use temporaries to guess loop dimensions, as temporaries' bounds are
calculated from loop dimensions. 

In the union:
union
{                           
  struct { ... } scalar;                         
  struct { ... } temp;
  struct gfc_ss_info info
}                           
data;

We are currently accessing data.struct.info even in the GFC_SS_TEMP case where
it is not defined. However, the aliasing and the code interact in such a way
that the temporary is never chosen to get loop bounds; so it works.

This patch prevents accessing gfc_ss::data::info in cases it has invalid
content, so that we can update gfc_ss_info without caring about aliasing
problems.
OK?
2011-10-19  Mikael Morin  <mik...@gcc.gnu.org>

        * trans-array.c (gfc_conv_loop_setup): Also skip temporary arrays.
diff --git a/trans-array.c b/trans-array.c
index f4d8a85..cfbe909 100644
--- a/trans-array.c
+++ b/trans-array.c
@@ -3881,7 +3881,12 @@ gfc_conv_loop_setup (gfc_loopinfo * loop, locus * where)
 	 loop for this dimension.  We try to pick the simplest term.  */
       for (ss = loop->ss; ss != gfc_ss_terminator; ss = ss->loop_chain)
 	{
-	  if (ss->type == GFC_SS_SCALAR || ss->type == GFC_SS_REFERENCE)
+	  gfc_ss_type ss_type;
+
+	  ss_type = ss->type;
+	  if (ss_type == GFC_SS_SCALAR
+	      || ss_type == GFC_SS_TEMP
+	      || ss_type == GFC_SS_REFERENCE)
 	    continue;
 
 	  info = &ss->data.info;

Reply via email to