aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-expr.cc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2024-12-10 19:43:14 +0100
committerMarc Poulhiès <dkm@gcc.gnu.org>2025-01-06 10:14:48 +0100
commit7067e6f6ff9bf9c640a8f1e3193fad195d20f6c3 (patch)
treee648a79663e5cf5bcb1171edec3a39c7b2289dfc /gcc/fortran/trans-expr.cc
parent6be06ae88b8be8543094d712f24c52a4d2d73220 (diff)
downloadgcc-7067e6f6ff9bf9c640a8f1e3193fad195d20f6c3.zip
gcc-7067e6f6ff9bf9c640a8f1e3193fad195d20f6c3.tar.gz
gcc-7067e6f6ff9bf9c640a8f1e3193fad195d20f6c3.tar.bz2
ada: Fix memory leak when failing to initialize newly allocated memory
This makes the compiler generate cleanup code to deallocate the memory when the evaluation of the expression of an allocator raises an exception, if the expression is a call to a function that may raise, i.e. is not declared with the No_Raise aspect/pragma. This can also be disabled by means of -gnatdQ. gcc/ada/ChangeLog: * debug.adb (dQ): Document usage. * exp_ch4.ads (Build_Cleanup_For_Allocator): New declaration. * exp_ch4.adb (Build_Cleanup_For_Allocator): New procedure. (Expand_Allocator_Expression): Build a cleanup to deallocate the memory when the evaluation of the expression raises an exception. * exp_ch6.adb (Make_Build_In_Place_Call_In_Allocator): Likewise. * exp_util.adb (Build_Allocate_Deallocate_Proc): Do not generate the detachment if the deallocation is for the cleanup of an allocator. * gen_il-fields.ads (Opt_Field_Enum): Add For_Allocator. * gen_il-gen-gen_nodes.adb (N_Free_Statement): Likewise. * sinfo.ads (For_Allocator): Document usage on N_Free_Statement.
Diffstat (limited to 'gcc/fortran/trans-expr.cc')
0 files changed, 0 insertions, 0 deletions