re PR fortran/35994 (MAXLOC and MINLOC off by one with mask)
authorJerry DeLisle <jvdelisle@gcc.gnu.org>
Thu, 24 Apr 2008 03:48:00 +0000 (03:48 +0000)
committerJerry DeLisle <jvdelisle@gcc.gnu.org>
Thu, 24 Apr 2008 03:48:00 +0000 (03:48 +0000)
2008-04-23  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
    Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

PR fortran/35994
* trans-instrinsic.c (gfc_conv_intrinsic_minmaxloc): Correctly adjust
loop counter offset.

Co-Authored-By: Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
From-SVN: r134615

gcc/fortran/ChangeLog
gcc/fortran/trans-intrinsic.c

index dedc52ad0e0ee735b3474f08e318ec44770c7bcd..4de64f1951d240adc04840a48fcb562b4e0eba26 100644 (file)
@@ -1,3 +1,10 @@
+2008-04-23  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+           Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
+
+       PR fortran/35994
+       * trans-instrinsic.c (gfc_conv_intrinsic_minmaxloc): Correctly adjust
+       loop counter offset.
+
 2008-04-23  Paolo Bonzini  <bonzini@gnu.org>
 
        * trans-expr.c (gfc_conv_structure): Don't set TREE_INVARIANT.
index e832b8a30e99c8a533876ecfee129a0f3f64aaba..f3cd4de9bca0e3a0d4708dee0466e09b441cd4fa 100644 (file)
@@ -2171,11 +2171,12 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, int op)
 
   /* Remember where we are.  An offset must be added to the loop
      counter to obtain the required position.  */
-  if (loop.temp_dim)
-    tmp = build_int_cst (gfc_array_index_type, 1);
+  if (loop.from[0])
+    tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type,
+                      gfc_index_one_node, loop.from[0]);
   else
-    tmp =fold_build2 (MINUS_EXPR, gfc_array_index_type,
-                        gfc_index_one_node, loop.from[0]);
+    tmp = build_int_cst (gfc_array_index_type, 1);
+  
   gfc_add_modify_expr (&block, offset, tmp);
 
   tmp = fold_build2 (PLUS_EXPR, TREE_TYPE (pos),