]> 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 19:19:55 +0000 (21:19 +0200)
committerMikael Morin <mikael@gcc.gnu.org>
Thu, 1 Sep 2011 19:19:55 +0000 (19:19 +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: r178427

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 10e5800f039531f9ce99d057f134623ba4d8d258..f8d74f64a8ab0a82c5dbed1ca4a632e0c5da92db 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-04-16  Release Manager
 
        * GCC 4.4.6 released.
index 595b46efee9c6ce9d7a30193ebf678ba01c716cf..4d5421d64b14903fa46c4014c960caadb65102bc 100644 (file)
@@ -5180,10 +5180,19 @@ 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 f8b966e7d9269cddcb55a3ab7f50dad2c8ef8e39..91596946f0a6946bdf065d5eec759782623dc047 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-19  Tobias Burnus  <burnus@net-b.de>
 
        Backport from mainline
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" } }