]> gcc.gnu.org Git - gcc.git/blobdiff - gcc/fortran/trans-stmt.c
re PR fortran/22038 (Forall with mask broken)
[gcc.git] / gcc / fortran / trans-stmt.c
index 55543182f8d32ec9e218a40633b76f22f4f46e2c..6670f543609d4069fbc75a0bedb729412f4ef58b 100644 (file)
@@ -37,8 +37,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "trans-const.h"
 #include "arith.h"
 
-int has_alternate_specifier;
-
 typedef struct iter_info
 {
   tree var;
@@ -206,6 +204,7 @@ tree
 gfc_trans_call (gfc_code * code)
 {
   gfc_se se;
+  int has_alternate_specifier;
 
   /* A CALL starts a new block because the actual arguments may have to
      be evaluated first.  */
@@ -213,10 +212,10 @@ gfc_trans_call (gfc_code * code)
   gfc_start_block (&se.pre);
 
   gcc_assert (code->resolved_sym);
-  has_alternate_specifier = 0;
 
   /* Translate the call.  */
-  gfc_conv_function_call (&se, code->resolved_sym, code->ext.actual);
+  has_alternate_specifier
+    = gfc_conv_function_call (&se, code->resolved_sym, code->ext.actual);
 
   /* A subroutine without side-effect, by definition, does nothing!  */
   TREE_SIDE_EFFECTS (se.expr) = 1;
@@ -1365,8 +1364,9 @@ gfc_trans_forall_loop (forall_info *forall_tmp, int nvar, tree body, int mask_fl
       tmp = build2 (PLUS_EXPR, TREE_TYPE (var), var, step);
       gfc_add_modify_expr (&block, var, tmp);
 
-      /* Advance to the next mask element.  */
-      if (mask_flag)
+      /* Advance to the next mask element.  Only do this for the
+        innermost loop.  */
+      if (n == 0 && mask_flag)
         {
           mask = forall_tmp->mask;
           maskindex = forall_tmp->maskindex;
This page took 0.030632 seconds and 5 git commands to generate.