diff options
author | Andrew Jenner <andrew@codesourcery.com> | 2023-11-28 15:27:05 +0000 |
---|---|---|
committer | Andrew Jenner <andrew@codesourcery.com> | 2023-11-28 15:27:05 +0000 |
commit | b247e917ff13328298c1eecf8563b12edd7ade04 (patch) | |
tree | 4deaf6bf9094ceec5bd0f697ec2d825f08daf66d /gcc/prefix.h | |
parent | f31a019d1161ec78846473da743aedf49cca8c27 (diff) | |
download | gcc-b247e917ff13328298c1eecf8563b12edd7ade04.zip gcc-b247e917ff13328298c1eecf8563b12edd7ade04.tar.gz gcc-b247e917ff13328298c1eecf8563b12edd7ade04.tar.bz2 |
Fortran: fix reallocation on assignment of polymorphic variables [PR110415]
This patch fixes two bugs related to polymorphic class assignment in the
Fortran front-end. One (described in PR110415) is an issue with the malloc
and realloc calls using the size from the old vptr rather than the new one.
The other is caused by the return value from the realloc call being ignored.
Testcases are added for these issues.
2023-11-28 Andrew Jenner <andrew@codesourcery.com>
gcc/fortran/
PR fortran/110415
* trans-expr.cc (trans_class_vptr_len_assignment): Add
from_vptrp parameter. Populate it. Don't check for DECL_P
when deciding whether to create temporary.
(trans_class_pointer_fcn, gfc_trans_pointer_assignment): Add
NULL argument to trans_class_vptr_len_assignment calls.
(trans_class_assignment): Get rhs_vptr from
trans_class_vptr_len_assignment and use it for determining size
for allocation/reallocation. Use return value from realloc.
gcc/testsuite/
PR fortran/110415
* gfortran.dg/pr110415.f90: New test.
* gfortran.dg/asan/pr110415-2.f90: New test.
* gfortran.dg/asan/pr110415-3.f90: New test.
Co-Authored-By: Tobias Burnus <tobias@codesourcery.com>
Diffstat (limited to 'gcc/prefix.h')
0 files changed, 0 insertions, 0 deletions