aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-array.cc
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2025-02-20 21:22:56 +0100
committerHarald Anlauf <anlauf@gmx.de>2025-02-21 09:30:05 +0100
commit7d383a7343af052798a52d575a0f0205c4a82c9c (patch)
treec47079e4a169c52e0b0958920be74194b135f5e5 /gcc/fortran/trans-array.cc
parent08bdc2ac98ae05ef694f4e55c296835fc01a3673 (diff)
downloadgcc-7d383a7343af052798a52d575a0f0205c4a82c9c.zip
gcc-7d383a7343af052798a52d575a0f0205c4a82c9c.tar.gz
gcc-7d383a7343af052798a52d575a0f0205c4a82c9c.tar.bz2
Fortran: initialize non-saved pointers with -fcheck=pointer [PR48958]
PR fortran/48958 gcc/fortran/ChangeLog: * trans-array.cc (gfc_trans_deferred_array): Initialize the data component of non-saved pointers when -fcheck=pointer is set. gcc/testsuite/ChangeLog: * gfortran.dg/pointer_init_13.f90: New test.
Diffstat (limited to 'gcc/fortran/trans-array.cc')
-rw-r--r--gcc/fortran/trans-array.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 92e933a..8f76870 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -12123,8 +12123,11 @@ gfc_trans_deferred_array (gfc_symbol * sym, gfc_wrapped_block * block)
type = TREE_TYPE (descriptor);
}
- /* NULLIFY the data pointer, for non-saved allocatables. */
- if (GFC_DESCRIPTOR_TYPE_P (type) && !sym->attr.save && sym->attr.allocatable)
+ /* NULLIFY the data pointer for non-saved allocatables, or for non-saved
+ pointers when -fcheck=pointer is specified. */
+ if (GFC_DESCRIPTOR_TYPE_P (type) && !sym->attr.save
+ && (sym->attr.allocatable
+ || (sym->attr.pointer && (gfc_option.rtcheck & GFC_RTCHECK_POINTER))))
{
gfc_conv_descriptor_data_set (&init, descriptor, null_pointer_node);
if (flag_coarray == GFC_FCOARRAY_LIB && sym->attr.codimension)