------- Comment #2 from pault at gcc dot gnu dot org  2008-03-26 22:20 -------
This one is relatively easy:

Index: gcc/fortran/trans-array.c
===================================================================
*** gcc/fortran/trans-array.c   (revision 133278)
--- gcc/fortran/trans-array.c   (working copy)
*************** gfc_conv_loop_setup (gfc_loopinfo * loop
*** 3506,3512 ****
          a.ubound[n] = specified_upper_bound;
          a.stride[n] = stride;
          size = ubound + size; //size = ubound + 1 - lbound
!         stride = stride * size;
        }
      return (stride);
     }  */
--- 3516,3522 ----
          a.ubound[n] = specified_upper_bound;
          a.stride[n] = stride;
          size = ubound + size; //size = ubound + 1 - lbound
!         stride = size >= 0 ? stride * size : 0;
        }
      return (stride);
     }  */
*************** gfc_array_init_size (tree descriptor, in
*** 3605,3610 ****
--- 3615,3623 ----
        else
        or_expr = fold_build2 (TRUTH_OR_EXPR, boolean_type_node, or_expr,
cond);


+       size = fold_build3 (COND_EXPR, gfc_array_index_type, cond,
+                         size, gfc_index_zero_node);
+
        /* Multiply the stride by the number of elements in this dimension.  */
        stride = fold_build2 (MULT_EXPR, gfc_array_index_type, stride, size);
        stride = gfc_evaluate_now (stride, pblock);

I'll put it on to regtest.

Paul


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pault at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2008-03-25 23:52:07         |2008-03-26 22:20:33
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35698

Reply via email to