]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/63152 (needless initialization of local pointer arrays.)
authorJoost VandeVondele <vondele@gcc.gnu.org>
Fri, 19 Sep 2014 10:28:00 +0000 (10:28 +0000)
committerJoost VandeVondele <vondele@gcc.gnu.org>
Fri, 19 Sep 2014 10:28:00 +0000 (10:28 +0000)
2014-09-19  Joost VandeVondele  <vondele@gcc.gnu.org>

PR fortran/63152
* trans-array.c (gfc_trans_deferred_array): Only nullify allocatables.

2014-09-19  Joost VandeVondele  <vondele@gcc.gnu.org>

PR fortran/63152
* gfortran.dg/auto_char_dummy_array_1.f90: Fix undefined behavior.
* gfortran.dg/pr63152.f90: New test.

From-SVN: r215387

gcc/fortran/ChangeLog
gcc/fortran/trans-array.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/auto_char_dummy_array_1.f90

index fe5628b827234a64afd7b468244c335a31886ba7..f2bc626fb01c9da9efd6fb469ff15b6323f84453 100644 (file)
@@ -1,3 +1,8 @@
+2014-09-19  Joost VandeVondele  <vondele@gcc.gnu.org>
+
+       PR fortran/63152
+       * trans-array.c (gfc_trans_deferred_array): Only nullify allocatables.
+
 2014-09-15  Jakub Jelinek  <jakub@redhat.com>
 
        * Make-lang.in (check_gfortran_parallelize): Change to just an upper
index 123df5d484edbf2b64be924b2c0fc0500b56f0dd..3ac652385061b968af2d4b7fada94fe5abc560e4 100644 (file)
@@ -8647,8 +8647,8 @@ gfc_trans_deferred_array (gfc_symbol * sym, gfc_wrapped_block * block)
       type = TREE_TYPE (descriptor);
     }
 
-  /* NULLIFY the data pointer.  */
-  if (GFC_DESCRIPTOR_TYPE_P (type) && !sym->attr.save)
+  /* NULLIFY the data pointer, for non-saved allocatables.  */
+  if (GFC_DESCRIPTOR_TYPE_P (type) && !sym->attr.save && sym->attr.allocatable)
     gfc_conv_descriptor_data_set (&init, descriptor, null_pointer_node);
 
   gfc_restore_backend_locus (&loc);
index 0de1ff84bf3b06aa12f939a3b9e346b8997e090c..b0f2bc80696e4cf1555d94c4cdf1b42b83abbbcc 100644 (file)
@@ -1,3 +1,9 @@
+2014-09-19  Joost VandeVondele  <vondele@gcc.gnu.org>
+
+       PR fortran/63152
+       * gfortran.dg/auto_char_dummy_array_1.f90: Fix undefined behavior.
+       * gfortran.dg/pr63152.f90: New test.
+
 2014-09-19  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/58328
index 6a660c203883da50a8ea2ef291cc5bdb7d0f7f8a..f24ce887643096b83c8c9072af2a7266a547cedd 100644 (file)
@@ -11,6 +11,8 @@ end module global
 program oh_no_not_pr15908_again
   character(12), dimension(:), pointer :: ptr
 
+  nullify(ptr)
+
   call a (ptr, 12)
   if (.not.associated (ptr) ) call abort ()
   if (any (ptr.ne."abc")) call abort ()