]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/61138 (Wrong code with pointer-bounds remapping)
authorMikael Morin <mikael@gcc.gnu.org>
Sat, 21 Mar 2015 15:15:19 +0000 (15:15 +0000)
committerMikael Morin <mikael@gcc.gnu.org>
Sat, 21 Mar 2015 15:15:19 +0000 (15:15 +0000)
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: r221555

gcc/fortran/ChangeLog
gcc/fortran/trans-expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pointer_remapping_9.f90 [new file with mode: 0644]

index f762bb93cacfb1028b5bf2ddc723af50acf9c399..10cba1aba1a9a1934af5fb0c18e9cc32fa286ad1 100644 (file)
@@ -1,4 +1,10 @@
-2014-03-19  Paul Thomas  <pault@gcc.gnu.org>
+2015-03-21  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-19  Paul Thomas  <pault@gcc.gnu.org>
 
        Backport from mainline
        PR fortran/59198
index 098bfdfec5b75b7e4c2adc8b9fd1be2ea8124a3d..a093445bb1496ed1933b472a13405393118dbe3e 100644 (file)
@@ -6663,6 +6663,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);
@@ -6678,6 +6679,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;
@@ -6728,6 +6730,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);
index 31de6375b9c9b8d0fa937f7fb3b7776f763eed21..a1f17bd302fe43b4e5df0bb4bbd19658a03babe5 100644 (file)
@@ -1,4 +1,9 @@
-2014-03-19  Paul Thomas  <pault@gcc.gnu.org>
+2015-03-21  Mikael Morin  <mikael@gcc.gnu.org>
+
+       PR fortran/61138
+       * gfortran.dg/pointer_remapping_9.f90: New.
+
+2015-03-19  Paul Thomas  <pault@gcc.gnu.org>
 
        Backport from mainline
        PR fortran/59198
diff --git a/gcc/testsuite/gfortran.dg/pointer_remapping_9.f90 b/gcc/testsuite/gfortran.dg/pointer_remapping_9.f90
new file mode 100644 (file)
index 0000000..7c1e232
--- /dev/null
@@ -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
+