]> 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@gcc.gnu.org>
Thu, 25 Aug 2011 19:10:06 +0000 (19:10 +0000)
committerMikael Morin <mikael@gcc.gnu.org>
Thu, 25 Aug 2011 19:10:06 +0000 (19:10 +0000)
2011-08-25  Mikael Morin  <mikael.morin@gcc.gnu.org>

PR fortran/50050
* expr.c (gfc_free_shape): Do nothing if shape is NULL.
(free_expr0): Remove redundant NULL shape check.
* resolve.c (check_host_association): Ditto.
* trans-expr.c (gfc_trans_subarray_assign): Assert that shape is
non-NULL.
* trans-io.c (transfer_array_component): Ditto.

2011-08-25  Mikael Morin  <mikael.morin@gcc.gnu.org>

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

From-SVN: r178086

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

index 5cab38d5c8582c597a59a0652c2fe2ccf5f3686a..be796bae6e150584f79af5f5e8d7ab3dff31afe1 100644 (file)
@@ -1,3 +1,13 @@
+2011-08-25  Mikael Morin  <mikael.morin@gcc.gnu.org>
+
+       PR fortran/50050
+       * expr.c (gfc_free_shape): Do nothing if shape is NULL.
+       (free_expr0): Remove redundant NULL shape check.
+       * resolve.c (check_host_association): Ditto.
+       * trans-expr.c (gfc_trans_subarray_assign): Assert that shape is
+       non-NULL.
+       * trans-io.c (transfer_array_component): Ditto.
+
 2011-08-25  Tobias Burnus  <burnus@net-b.de>
 
        * trans-array.c (gfc_conv_descriptor_token): Add assert.
index b050b116ca5d004674518622e94bc8211fe36a53..3c09a2a99c4b11a7b459170e25860977900be76f 100644 (file)
@@ -409,6 +409,9 @@ gfc_clear_shape (mpz_t *shape, int rank)
 void
 gfc_free_shape (mpz_t **shape, int rank)
 {
+  if (*shape == NULL)
+    return;
+
   gfc_clear_shape (*shape, rank);
   free (*shape);
   *shape = NULL;
@@ -490,8 +493,7 @@ free_expr0 (gfc_expr *e)
     }
 
   /* Free a shape array.  */
-  if (e->shape != NULL)
-    gfc_free_shape (&e->shape, e->rank);
+  gfc_free_shape (&e->shape, e->rank);
 
   gfc_free_ref_list (e->ref);
 
index e3427230c886b64d0fe148a548336129a618f943..436c16045cbe4c26065e2fb741ea5a849c03573e 100644 (file)
@@ -5198,8 +5198,7 @@ check_host_association (gfc_expr *e)
              && sym->attr.contained)
        {
          /* Clear the shape, since it might not be valid.  */
-         if (e->shape != NULL)
-           gfc_free_shape (&e->shape, e->rank);
+         gfc_free_shape (&e->shape, e->rank);
 
          /* Give the expression the right symtree!  */
          gfc_find_sym_tree (e->symtree->name, NULL, 1, &st);
index 628930a340dcda47014cfd20eac1cf08239ebaae..ea65c022cf57baebf0abda5fbebf784d4373dc72 100644 (file)
@@ -4428,6 +4428,7 @@ gfc_trans_subarray_assign (tree dest, gfc_component * cm, gfc_expr * expr)
   gfc_add_block_to_block (&block, &loop.pre);
   gfc_add_block_to_block (&block, &loop.post);
 
+  gcc_assert (lss->shape != NULL);
   gfc_free_shape (&lss->shape, cm->as->rank);
   gfc_cleanup_loop (&loop);
 
index 2ae34d8f25acdeffa2cc93a0a0bc0d4dd3bd04d9..931565d72fe147d78772876df1c15ba6cf7b2873 100644 (file)
@@ -1999,6 +1999,7 @@ transfer_array_component (tree expr, gfc_component * cm, locus * where)
   gfc_add_block_to_block (&block, &loop.pre);
   gfc_add_block_to_block (&block, &loop.post);
 
+  gcc_assert (ss->shape != NULL);
   gfc_free_shape (&ss->shape, cm->as->rank);
   gfc_cleanup_loop (&loop);
 
index c64661263d8e186336b4ceecf830be4f8cd7df8b..417f0f124ca499f1b09e9ded97f67226fddc86cf 100644 (file)
@@ -1,3 +1,8 @@
+2011-08-25  Mikael Morin  <mikael.morin@gcc.gnu.org>
+
+       PR fortran/50050
+       * gfortran.dg/pointer_comp_init_1.f90: New test.
+
 2011-08-25  Jason Merrill  <jason@redhat.com>
 
        PR c++/50157
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" } }