re PR fortran/71194 (ICE on compilation with fcheck=all ; -fcheck=bounds)
authorTobias Burnus <burnus@net-b.de>
Mon, 20 Jun 2016 18:46:43 +0000 (20:46 +0200)
committerTobias Burnus <burnus@gcc.gnu.org>
Mon, 20 Jun 2016 18:46:43 +0000 (20:46 +0200)
2016-06-20  Tobias Burnus  <burnus@net-b.de>

        fortran/71194
        * trans-expr.c (gfc_trans_pointer_assignment): Correctly handle
        RHS pointer functions.

2016-06-20  Tobias Burnus  <burnus@net-b.de>

        PR fortran/71194
        * gfortran.dg/pointer_remapping_10.f90: New.

From-SVN: r237612

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

index d1f384ecc14f3a6a74c3e97613d2de15109ca4dc..bfd3d4ef6f714d4762f76562caf6f2d7c3c168fc 100644 (file)
@@ -1,3 +1,9 @@
+2016-06-20  Tobias Burnus  <burnus@net-b.de>
+
+       fortran/71194
+       * trans-expr.c (gfc_trans_pointer_assignment): Correctly handle
+       RHS pointer functions.
+
 2016-06-19  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>
 
        * class.c (gfc_add_class_array_ref): Call gfc_add_data_component()
index 8f84712931bbae45a70a8dee979cd60fd5be080f..b5731aa8bbe2a48cc8bfddf21b5cc4a2edaeb1da 100644 (file)
@@ -7934,11 +7934,11 @@ 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);
-             strlen_rhs = lse.string_length;
+             rse.descriptor_only = 0;
+             rse.expr = tmp;
+             rse.direct_byref = 1;
+             gfc_conv_expr_descriptor (&rse, expr2);
+             strlen_rhs = rse.string_length;
              rse.expr = tmp;
            }
          else
index 1d438528a07b7d894c742abac472fe4412c30150..d42a9d71e8e68e744c47d009baec4f93689ff5cf 100644 (file)
@@ -1,3 +1,8 @@
+2016-06-20  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/71194
+       * gfortran.dg/pointer_remapping_10.f90: New.
+
 2016-06-20  David Malcolm  <dmalcolm@redhat.com>
 
        * g++.dg/diagnostic/string-literal-concat.C: New test case.
diff --git a/gcc/testsuite/gfortran.dg/pointer_remapping_10.f90 b/gcc/testsuite/gfortran.dg/pointer_remapping_10.f90
new file mode 100644 (file)
index 0000000..4810506
--- /dev/null
@@ -0,0 +1,46 @@
+! { dg-do run }
+! { dg-options "-fcheck=all" }
+!
+! PR fortran/71194
+!
+! Contributed by T Kondic
+!
+program ice
+implicit none
+integer, parameter :: pa=10, pb=20
+complex, target :: a(pa*pb)
+real, pointer:: ptr(:,:) =>null()
+integer :: i, j, cnt
+logical :: negative
+
+  do i = 1, size(a)
+    a(i) = cmplx(i,-i)
+  end do
+
+  ! Was ICEing before with bounds checks
+  ptr(1:pa*2,1:pb) => conv2real(a)
+
+  negative = .false.
+  cnt = 1
+  do i = 1, ubound(ptr,dim=2)
+    do j = 1, ubound(ptr,dim=1)
+      if (negative) then
+        if (-cnt /= ptr(j, i)) call abort()
+        cnt = cnt + 1
+        negative = .false.
+      else
+        if (cnt /= ptr(j, i)) call abort()
+        negative = .true.
+      end if
+    end do 
+  end do
+
+contains
+  function conv2real(carr)
+    use, intrinsic :: iso_c_binding
+    ! returns real pointer to a complex array
+    complex, contiguous, intent(inout), target  :: carr(:)
+    real,contiguous,pointer :: conv2real(:)
+    call c_f_pointer(c_loc(carr),conv2real,[size(carr)*2])
+  end function conv2real
+end program