]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/50050 (Internal compiler error free_expr0 at expr.c:3709 via gfc_done_2)
authorMikael Morin <mikael.morin@sfr.fr>
Thu, 1 Sep 2011 15:52:39 +0000 (17:52 +0200)
committerMikael Morin <mikael@gcc.gnu.org>
Thu, 1 Sep 2011 15:52:39 +0000 (15:52 +0000)
2011-09-01  Mikael Morin  <mikael.morin@sfr.fr>

PR fortran/50050
* resolve.c (gfc_expr_to_initialize): Don't copy rank.
Free copied shape.  Recalculate shape and rank.

2011-09-01  Mikael Morin  <mikael.morin@sfr.fr>

PR fortran/50050
* gfortran.dg/alloc_comp_initializer_3.f90: New test.
* gfortran.dg/pointer_comp_init.f90: New test.

From-SVN: r178424

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/alloc_comp_initializer_3.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/pointer_comp_init_1.f90 [new file with mode: 0644]

index b6733fc553ca40cdc36169f8cd31f9ec65aae0f6..c823d1828b96876ed549b2876d63d28e3be94f1d 100644 (file)
@@ -1,3 +1,9 @@
+2011-09-01  Mikael Morin  <mikael.morin@sfr.fr>
+
+       PR fortran/50050
+       * resolve.c (gfc_expr_to_initialize): Don't copy rank.
+       Free copied shape.  Recalculate shape and rank.
+
 2011-08-30  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/50163
index 1c606a3033cf4f339305fed84aed5d79130ca181..7abddb593a0ff40a3d3bf4dcdde36195c10a8933 100644 (file)
@@ -6172,10 +6172,19 @@ gfc_expr_to_initialize (gfc_expr *e)
        for (i = 0; i < ref->u.ar.dimen; i++)
          ref->u.ar.start[i] = ref->u.ar.end[i] = ref->u.ar.stride[i] = NULL;
 
-       result->rank = ref->u.ar.dimen;
        break;
       }
 
+  if (result->shape != NULL)
+    {
+      for (i = 0; i < result->rank; i++)
+       mpz_clear (result->shape[i]);
+      gfc_free (result->shape);
+      result->shape = NULL;
+    }
+
+  /* Recalculate rank, shape, etc.  */
+  gfc_resolve_expr (result);
   return result;
 }
 
index 81fcfe1534417dc6f5c5b562d1c5419826a6f64e..3ec6da5174bdfb0255db472a8fe4bfc2485295f8 100644 (file)
@@ -1,3 +1,9 @@
+2011-09-01  Mikael Morin  <mikael.morin@sfr.fr>
+
+       PR fortran/50050
+       * gfortran.dg/alloc_comp_initializer_3.f90: New test.
+       * gfortran.dg/pointer_comp_init.f90: New test.
+
 2011-08-30  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        Backport from trunk
diff --git a/gcc/testsuite/gfortran.dg/alloc_comp_initializer_3.f90 b/gcc/testsuite/gfortran.dg/alloc_comp_initializer_3.f90
new file mode 100644 (file)
index 0000000..014b069
--- /dev/null
@@ -0,0 +1,15 @@
+! { dg-do compile }
+!
+! PR fortran/50050
+! Out of bound whilst releasing initialization of allocate object
+!
+! Contributed by someone <sigurdkn@gmail.com>
+
+program bug
+  implicit none
+  type foo
+    integer, pointer :: a => null()
+  end type
+  type(foo), dimension(:,:), allocatable :: data
+  allocate(data(1:1,1)) ! This used to lead to an ICE
+end program
diff --git a/gcc/testsuite/gfortran.dg/pointer_comp_init_1.f90 b/gcc/testsuite/gfortran.dg/pointer_comp_init_1.f90
new file mode 100644 (file)
index 0000000..44f360e
--- /dev/null
@@ -0,0 +1,30 @@
+! { dg-do compile }
+!
+! PR fortran/50050
+! ICE whilst trying to access NULL shape.
+
+! Reduced from the FoX library http://www1.gly.bris.ac.uk/~walker/FoX/
+! Contributed by Andrew Benson <abenson@its.caltech.edu>
+
+module m_common_attrs
+  implicit none
+
+  type dict_item
+  end type dict_item
+
+  type dict_item_ptr
+     type(dict_item), pointer :: d => null()
+  end type dict_item_ptr
+
+contains
+
+  subroutine add_item_to_dict()
+    type(dict_item_ptr), pointer :: tempList(:)
+    integer :: n
+
+    allocate(tempList(0:n+1)) 
+  end subroutine add_item_to_dict
+
+end module m_common_attrs
+
+! { dg-final { cleanup-modules "m_common_attrs" } }