From: Mikael Morin Date: Sat, 14 Mar 2015 12:23:27 +0000 (+0000) Subject: re PR fortran/61138 (Wrong code with pointer-bounds remapping) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=375e632759babad9111f2c4eadcb69a9fe95906f;p=gcc.git 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 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index d7d854389e6..30107c977af 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2015-03-14 Mikael Morin + + PR fortran/61138 + * trans-expr.c (gfc_trans_pointer_assignment): Clear DESCRIPTOR_ONLY + field before reusing LSE. + 2015-03-11 Janne Blomqvist PR libfortran/65200 diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 353d0120d9d..8af8be287ee 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cbd544d12b1..b4e8ac8aa89 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-03-14 Mikael Morin + + PR fortran/61138 + gfortran.dg/pointer_remapping_9.f90: New. + 2015-03-14 Jakub Jelinek PR tree-optimization/65369 diff --git a/gcc/testsuite/gfortran.dg/pointer_remapping_9.f90 b/gcc/testsuite/gfortran.dg/pointer_remapping_9.f90 new file mode 100644 index 00000000000..7c1e2320b4b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pointer_remapping_9.f90 @@ -0,0 +1,31 @@ +! { dg-do run } +! +! PR fortran/61138 +! Wrong code with pointer-bounds remapping +! +! Contributed by Tobias Burnus + +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 +