OSDN Git Service

* trans.h (struct gfc_ss): New field parent.
[pf3gnuchains/gcc-fork.git] / gcc / fortran / trans-expr.c
index b175b62..72d35f8 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;
     }
@@ -2898,7 +2907,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
       if (!sym->attr.elemental)
        {
          gcc_assert (se->ss->info->type == GFC_SS_FUNCTION);
-         if (se->ss->useflags)
+         if (se->ss->info->useflags)
            {
              gcc_assert ((!comp && gfc_return_by_reference (sym)
                           && sym->result->attr.dimension)
@@ -2983,7 +2992,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
          gfc_init_se (&parmse, se);
          gfc_conv_derived_to_class (&parmse, e, fsym->ts);
        }
-      else if (se->ss && se->ss->useflags)
+      else if (se->ss && se->ss->info->useflags)
        {
          /* An elemental function inside a scalarized loop.  */
          gfc_init_se (&parmse, se);
@@ -3606,7 +3615,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
             returns a pointer, the temporary will be a shallow copy and
             mustn't be deallocated.  */
          callee_alloc = comp->attr.allocatable || comp->attr.pointer;
-         gfc_trans_create_temp_array (&se->pre, &se->post, se->loop, se->ss,
+         gfc_trans_create_temp_array (&se->pre, &se->post, se->ss,
                                       tmp, NULL_TREE, false,
                                       !comp->attr.pointer, callee_alloc,
                                       &se->ss->info->expr->where);
@@ -3642,7 +3651,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
             returns a pointer, the temporary will be a shallow copy and
             mustn't be deallocated.  */
          callee_alloc = sym->attr.allocatable || sym->attr.pointer;
-         gfc_trans_create_temp_array (&se->pre, &se->post, se->loop, se->ss,
+         gfc_trans_create_temp_array (&se->pre, &se->post, se->ss,
                                       tmp, NULL_TREE, false,
                                       !sym->attr.pointer, callee_alloc,
                                       &se->ss->info->expr->where);