===================================================================
@@ -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 ()
===================================================================
@@ -0,0 +1,17 @@
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+!
+! PR 63152 : needless init of local pointer arrays
+!
+! Contributed by Joost VandeVondele <vondele@gcc.gnu.org>
+ SUBROUTINE S1()
+ INTEGER, POINTER, DIMENSION(:) :: v
+ INTERFACE
+ SUBROUTINE foo(v)
+ INTEGER, POINTER, DIMENSION(:) :: v
+ END SUBROUTINE
+ END INTERFACE
+ CALL foo(v)
+ END SUBROUTINE S1
+! { dg-final { scan-tree-dump-times "= 0B" 0 "original" } }
+! { dg-final { cleanup-tree-dump "original" } }
===================================================================
@@ -8647,8 +8647,8 @@ gfc_trans_deferred_array (gfc_symbol * s
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);