===================================================================
*************** gfc_get_array_span (tree desc, gfc_expr
else
{
/* If none of the fancy stuff works, the span is the element
! size of the array. */
tmp = gfc_get_element_type (TREE_TYPE (desc));
! tmp = fold_convert (gfc_array_index_type,
! size_in_bytes (tmp));
}
return tmp;
}
else
{
/* If none of the fancy stuff works, the span is the element
! size of the array. Attempt to deal with unbounded character
! types if possible. Otherwise, return NULL_TREE. */
tmp = gfc_get_element_type (TREE_TYPE (desc));
! if (tmp && TREE_CODE (tmp) == ARRAY_TYPE
! && TYPE_MAX_VALUE (TYPE_DOMAIN (tmp)) == NULL_TREE)
! {
! if (expr->expr_type == EXPR_VARIABLE
! && expr->ts.type == BT_CHARACTER)
! tmp = fold_convert (gfc_array_index_type,
! gfc_get_expr_charlen (expr));
! else
! tmp = NULL_TREE;
! }
! else
! tmp = fold_convert (gfc_array_index_type,
! size_in_bytes (tmp));
}
return tmp;
}
*************** gfc_conv_expr_descriptor (gfc_se *se, gf
/* ....and set the span field. */
tmp = gfc_get_array_span (desc, expr);
! gfc_conv_descriptor_span_set (&se->pre, se->expr, tmp);
}
else if (se->want_pointer)
{
/* ....and set the span field. */
tmp = gfc_get_array_span (desc, expr);
! if (tmp != NULL_TREE)
! gfc_conv_descriptor_span_set (&se->pre, se->expr, tmp);
}
else if (se->want_pointer)
{
*************** gfc_conv_expr_descriptor (gfc_se *se, gf
desc = info->descriptor;
if (se->direct_byref && !se->byref_noassign)
{
! /* For pointer assignments we fill in the destination.... */
parm = se->expr;
parmtype = TREE_TYPE (parm);
-
- /* ....and set the span field. */
- tmp = gfc_get_array_span (desc, expr);
- gfc_conv_descriptor_span_set (&loop.pre, parm, tmp);
}
else
{
desc = info->descriptor;
if (se->direct_byref && !se->byref_noassign)
{
! /* For pointer assignments we fill in the destination. */
parm = se->expr;
parmtype = TREE_TYPE (parm);
}
else
{
*************** gfc_conv_expr_descriptor (gfc_se *se, gf
}
}
+ /* Set the span field. */
+ tmp = gfc_get_array_span (desc, expr);
+ if (tmp != NULL_TREE)
+ gfc_conv_descriptor_span_set (&loop.pre, parm, tmp);
+
offset = gfc_index_zero_node;
/* The following can be somewhat confusing. We have two
===================================================================
*************** end
! cases will all yield a temporary, so that atmp appears 18 times.
! Note that it is the kind conversion that generates the temp.
!
! ! { dg-final { scan-tree-dump-times "parm" 18 "original" } }
! { dg-final { scan-tree-dump-times "atmp" 18 "original" } }
! cases will all yield a temporary, so that atmp appears 18 times.
! Note that it is the kind conversion that generates the temp.
!
! ! { dg-final { scan-tree-dump-times "parm" 20 "original" } }
! { dg-final { scan-tree-dump-times "atmp" 18 "original" } }
===================================================================
***************
+ ! { dg-do run }
+ !
+ ! Test the fix for PR87336, in which the 'span' field of the array
+ ! descriptor, passed to 'show', was not set.
+ !
+ ! Contributed by Juergen Reuter <juergen.reuter@desy.de> following
+ ! a posting to clf by 'Spectrum'.
+ !
+ program main
+ implicit none
+ integer, target :: a( 2:4 )
+
+ a = [2,3,4]
+ ! print *, "a [before] = ", a
+ call show( a )
+ ! print *, "a [after] = ", a
+ if (any (a .ne. [200,300,400])) stop 1
+
+ contains
+ subroutine show( arr )
+ integer, pointer, intent(in) :: arr(:)
+ ! print *, "arr = ", arr
+ ! print *, "bounds = ", lbound(arr), ubound(arr)
+ arr(:) = [200,300,400]
+ ! print *, "arr2= ", arr
+ end subroutine show
+ end program
===================================================================
*************** end
!
! The check below for temporaries gave 14 and 33 for "parm" and "atmp".
!
! ! { dg-final { scan-tree-dump-times "parm" 66 "original" } }
! { dg-final { scan-tree-dump-times "atmp" 12 "original" } }
!
! The check below for temporaries gave 14 and 33 for "parm" and "atmp".
!
! ! { dg-final { scan-tree-dump-times "parm" 72 "original" } }
! { dg-final { scan-tree-dump-times "atmp" 12 "original" } }