------- Comment #6 from hjl at lucon dot org  2006-05-18 23:02 -------
This hack works for the testcase. But I don't know if it is the correct fix
or not.

2006-05-17  H.J. Lu  <[EMAIL PROTECTED]>

        PR fortran/27662
        * trans-expr.c (gfc_conv_function_call) Restore the first
        stride after the function call.

--- gcc/fortran/trans-expr.c.transpose  2006-04-16 11:18:33.000000000 -0700
+++ gcc/fortran/trans-expr.c    2006-05-18 15:55:30.000000000 -0700
@@ -2022,6 +2022,8 @@ gfc_conv_function_call (gfc_se * se, gfc
        retargs = gfc_chainon_list (retargs, se->expr);
       else if (sym->result->attr.dimension)
        {
+         tree stride;
+
          gcc_assert (se->loop && info);

          /* Set the type of the array.  */
@@ -2039,14 +2041,17 @@ gfc_conv_function_call (gfc_se * se, gfc
                                       false, !sym->attr.pointer,
callee_alloc);
          /* Zero the first stride to indicate a temporary.  */
-         tmp = gfc_conv_descriptor_stride (info->descriptor, gfc_rank_cst[0]);
-         gfc_add_modify_expr (&se->pre, tmp,
-                              convert (TREE_TYPE (tmp), integer_zero_node));
+         stride = gfc_conv_descriptor_stride (info->descriptor,
gfc_rank_cst[0]);
+         gfc_add_modify_expr (&se->pre, stride,
+                              convert (TREE_TYPE (stride),
integer_zero_node));
          /* Pass the temporary as the first argument.  */
          tmp = info->descriptor;
          tmp = build_fold_addr_expr (tmp);
          retargs = gfc_chainon_list (retargs, tmp);
+
+         /* Restore the first stride after the function call.  */
+         gfc_add_modify_expr (&post, stride, info->stride [0]);
        }
       else if (ts.type == BT_CHARACTER)
        {


-- 


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

Reply via email to