Commit 375e6327 by Mikael Morin

re PR fortran/61138 (Wrong code with pointer-bounds remapping)

	PR fortran/61138
fortran/
	* trans-expr.c (gfc_trans_pointer_assignment): Clear DESCRIPTOR_ONLY
	field before reusing LSE.
testsuite/
	gfortran.dg/pointer_remapping_9.f90: New.

From-SVN: r221436
parent d88981fc
2015-03-14 Mikael Morin <mikael@gcc.gnu.org>
PR fortran/61138
* trans-expr.c (gfc_trans_pointer_assignment): Clear DESCRIPTOR_ONLY
field before reusing LSE.
2015-03-11 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/65200
......
......@@ -7335,6 +7335,7 @@ gfc_trans_pointer_assignment (gfc_expr * expr1, gfc_expr * expr2)
bound, bound, 0,
GFC_ARRAY_POINTER_CONT, false);
tmp = gfc_create_var (tmp, "ptrtemp");
lse.descriptor_only = 0;
lse.expr = tmp;
lse.direct_byref = 1;
gfc_conv_expr_descriptor (&lse, expr2);
......@@ -7350,6 +7351,7 @@ gfc_trans_pointer_assignment (gfc_expr * expr1, gfc_expr * expr2)
else if (expr2->expr_type == EXPR_VARIABLE)
{
/* Assign directly to the LHS's descriptor. */
lse.descriptor_only = 0;
lse.direct_byref = 1;
gfc_conv_expr_descriptor (&lse, expr2);
strlen_rhs = lse.string_length;
......@@ -7401,6 +7403,7 @@ gfc_trans_pointer_assignment (gfc_expr * expr1, gfc_expr * expr2)
/* Assign to a temporary descriptor and then copy that
temporary to the pointer. */
tmp = gfc_create_var (TREE_TYPE (desc), "ptrtemp");
lse.descriptor_only = 0;
lse.expr = tmp;
lse.direct_byref = 1;
gfc_conv_expr_descriptor (&lse, expr2);
......
2015-03-14 Mikael Morin <mikael@gcc.gnu.org>
PR fortran/61138
gfortran.dg/pointer_remapping_9.f90: New.
2015-03-14 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/65369
......
! { dg-do run }
!
! PR fortran/61138
! Wrong code with pointer-bounds remapping
!
! Contributed by Tobias Burnus <burnus@net-b.de>
implicit none
integer, target :: tgt(10)
integer, target, allocatable :: tgt2(:)
integer, pointer :: ptr(:)
tgt = [1,2,3,4,5,6,7,8,9,10]
tgt2 = [1,2,3,4,5,6,7,8,9,10]
ptr(-5:) => tgt(5:) ! Okay
if (size(ptr) /= 6 .or. lbound(ptr,1) /= -5) call abort()
if (any (ptr /= [5,6,7,8,9,10])) call abort()
ptr(-5:) => tgt2(5:) ! wrongly associates the whole array
print '(*(i4))', size(ptr), lbound(ptr)
print '(*(i4))', ptr
if (size(ptr) /= 6 .or. lbound(ptr,1) /= -5) call abort()
if (any (ptr /= [5,6,7,8,9,10])) call abort()
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment