]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
trans.h (struct gfc_ss): New field parent.
authorMikael Morin <mikael@gcc.gnu.org>
Thu, 3 Nov 2011 23:17:08 +0000 (23:17 +0000)
committerMikael Morin <mikael@gcc.gnu.org>
Thu, 3 Nov 2011 23:17:08 +0000 (23:17 +0000)
* trans.h (struct gfc_ss): New field parent.
* trans-array.c (gfc_trans_scalarizing_loops): Skip clearing if a
parent exists.
* trans-expr.c (gfc_advance_se_ss_chain): Move to parent ss at the
end of the chain.

From-SVN: r180889

gcc/fortran/ChangeLog
gcc/fortran/trans-array.c
gcc/fortran/trans-expr.c
gcc/fortran/trans.h

index ce4e619b77833351e5c85d929222d3ee1b46ca0e..a552beade86aa75b32384600f2a5a3432fd556c2 100644 (file)
@@ -1,3 +1,11 @@
+2011-11-03  Mikael Morin  <mikael@gcc.gnu.org>
+
+       * trans.h (struct gfc_ss): New field parent.
+       * trans-array.c (gfc_trans_scalarizing_loops): Skip clearing if a
+       parent exists.
+       * trans-expr.c (gfc_advance_se_ss_chain): Move to parent ss at the
+       end of the chain.
+
 2011-11-03  Mikael Morin  <mikael@gcc.gnu.org>
 
        * trans-array.h (gfc_trans_create_temp_array): Remove loop argument.
index d386a228a0e4a4b97fa6f71c477340ecee2ebd52..abff8b5dc732457e5f31957c3728c51340354688 100644 (file)
@@ -3193,7 +3193,8 @@ gfc_trans_scalarizing_loops (gfc_loopinfo * loop, stmtblock_t * body)
 
   /* Clear all the used flags.  */
   for (ss = loop->ss; ss != gfc_ss_terminator; ss = ss->loop_chain)
-    ss->info->useflags = 0;
+    if (ss->parent == NULL)
+      ss->info->useflags = 0;
 }
 
 
index e091c89d6962b5fca7febb268ce16e2f7a2a7118..72d35f8de8946bc7c19dbbe6bc80b96ad6227ffd 100644 (file)
@@ -83,6 +83,7 @@ void
 gfc_advance_se_ss_chain (gfc_se * se)
 {
   gfc_se *p;
+  gfc_ss *ss;
 
   gcc_assert (se != NULL && se->ss != NULL && se->ss != gfc_ss_terminator);
 
@@ -93,7 +94,15 @@ gfc_advance_se_ss_chain (gfc_se * se)
       /* Simple consistency check.  */
       gcc_assert (p->parent == NULL || p->parent->ss == p->ss);
 
-      p->ss = p->ss->next;
+      /* If we were in a nested loop, the next scalarized expression can be
+        on the parent ss' next pointer.  Thus we should not take the next
+        pointer blindly, but rather go up one nest level as long as next
+        is the end of chain.  */
+      ss = p->ss;
+      while (ss->next == gfc_ss_terminator && ss->parent != NULL)
+       ss = ss->parent;
+
+      p->ss = ss->next;
 
       p = p->parent;
     }
index 62bcc643fb531e2c536ca1dcd9c7140c95e3f75c..53c5ce25fa4bc700ccd06c02bf9181ba4b17fe4d 100644 (file)
@@ -246,6 +246,9 @@ typedef struct gfc_ss
   struct gfc_ss *loop_chain;
   struct gfc_ss *next;
 
+  /* Non-null if the ss is part of a nested loop.  */
+  struct gfc_ss *parent;
+
   /* The loop this gfc_ss is in.  */
   struct gfc_loopinfo *loop;