]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/52386 (ICE in gfc_conv_descriptor_dtyp (realloc LHS related))
authorPaul Thomas <pault@gcc.gnu.org>
Wed, 29 Feb 2012 21:24:05 +0000 (21:24 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Wed, 29 Feb 2012 21:24:05 +0000 (21:24 +0000)
2012-02-29  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/52386
* trans-expr.c (fcncall_realloc_result): Dereference the
descriptor if needed.

2012-02-29  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/52386
* gfortran.dg/realloc_on_assign_13.f90 : New test.

From-SVN: r184673

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

index fc0237dd51ea6a4f2c497793b1fae69322edbc35..0e6d6139d2cd162361a46f9b0f2918792e44d785 100644 (file)
@@ -1,3 +1,9 @@
+2012-02-29  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/52386
+       * trans-expr.c (fcncall_realloc_result): Dereference the
+       descriptor if needed.
+
 2012-02-23  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/52335
index 3db1244bf25f76addab9acbd5adb86a77b3761c5..d86de0058bb73813588683f0d9371f0f1a501d9d 100644 (file)
@@ -5556,6 +5556,8 @@ fcncall_realloc_result (gfc_se *se, int rank)
   /* Use the allocation done by the library.  Substitute the lhs
      descriptor with a copy, whose data field is nulled.*/
   desc = build_fold_indirect_ref_loc (input_location, se->expr);
+  if (POINTER_TYPE_P (TREE_TYPE (desc)))
+    desc = build_fold_indirect_ref_loc (input_location, desc);
 
   /* Unallocated, the descriptor does not have a dtype.  */
   tmp = gfc_conv_descriptor_dtype (desc);
index 80bfd16e4777b4c65aabce1341dcf666a50ffe42..352e7356b0163427a2a33928ba60d084eb5a5f1e 100644 (file)
@@ -1,3 +1,8 @@
+2012-02-29  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/52386
+       * gfortran.dg/realloc_on_assign_13.f90 : New test.
+
 2012-02-23  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/52335
diff --git a/gcc/testsuite/gfortran.dg/realloc_on_assign_13.f90 b/gcc/testsuite/gfortran.dg/realloc_on_assign_13.f90
new file mode 100644 (file)
index 0000000..9661d72
--- /dev/null
@@ -0,0 +1,20 @@
+! { dg-do compile }
+! Test the fix for PR52386.
+!
+! Contributed by Juergen Reuter  <reuter@physik.uni-freiburg.de>
+!
+module cascades
+  implicit none
+  private
+contains
+    function reduced (array)
+      integer, dimension(:), allocatable :: reduced
+      integer, dimension(:), intent(in) :: array
+      logical, dimension(size(array)) :: mask
+      mask = .true. 
+      allocate (reduced (count (mask)))
+      reduced = pack (array, mask)
+    end function reduced
+end module cascades
+! { dg-final { cleanup-modules "cascades" } }
+