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
This commit is contained in:
Mikael Morin 2015-03-14 12:23:27 +00:00
parent d88981fc3e
commit 375e632759
4 changed files with 45 additions and 0 deletions

View File

@ -1,3 +1,9 @@
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

View File

@ -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);

View File

@ -1,3 +1,8 @@
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

View File

@ -0,0 +1,31 @@
! { 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