]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fortran: Free alloc. comp. in allocated coarrays only.
authorAndre Vehreschild <vehre@gcc.gnu.org>
Thu, 28 Sep 2023 07:30:12 +0000 (09:30 +0200)
committerAndre Vehreschild <vehre@gcc.gnu.org>
Fri, 29 Sep 2023 13:01:21 +0000 (15:01 +0200)
commitd9b3269bdccac2db9200303494c4e82f2aeb7bbc
tree0da2b132bce655b0469e6a1d76fbecf631abd8ae
parentb5b98a2d055d967d1fc92859827839c83c9368d7
Fortran: Free alloc. comp. in allocated coarrays only.

When freeing allocatable components of an allocatable coarray, add
a check that the coarray is still allocated, before accessing the
components.

This patch adds to PR fortran/37336, but does not fix it completely.

gcc/fortran/ChangeLog:
PR fortran/37336
* trans-array.cc (structure_alloc_comps): Deref coarray.
(gfc_trans_deferred_array): Add freeing of components after
check for allocated coarray.

gcc/testsuite/ChangeLog:
PR fortran/37336
* gfortran.dg/coarray/alloc_comp_6.f90: New test.
* gfortran.dg/coarray/alloc_comp_7.f90: New test.

(cherry picked from commit 9a63a62dfd73e159f1956e9b04b555c445de4e78)
gcc/fortran/trans-array.cc
gcc/testsuite/gfortran.dg/coarray/alloc_comp_6.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/coarray/alloc_comp_7.f90 [new file with mode: 0644]