aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.cc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2024-05-04 01:30:40 +0200
committerMarc Poulhiès <poulhies@adacore.com>2024-06-13 15:30:35 +0200
commitea3172a4247c11dbb90ed6484bbba97a2bbcc1f9 (patch)
treefb7931cc526ee98ed3e4b5acd99e1f2da78d1c4b /gcc/expr.cc
parentd7de75a0c28d505e60ceefccb508807a06a985e3 (diff)
downloadgcc-ea3172a4247c11dbb90ed6484bbba97a2bbcc1f9.zip
gcc-ea3172a4247c11dbb90ed6484bbba97a2bbcc1f9.tar.gz
gcc-ea3172a4247c11dbb90ed6484bbba97a2bbcc1f9.tar.bz2
ada: Fix segmentation fault on slice of array with Unbounded_String component
This fixes a regression introduced by the overhaul of the implementation of finalization. When the first subtype of an array type is declared as constrained, the Finalize_Address primitive of the base type synthesized by the compiler is tailored to this first subtype, which means that this primitive cannot be used for other subtypes of the array type, which may for example be generated when an aggregate is assigned to a slice of an object of the first subtype. The straightforward solution would be to synthesize the Finalize_Address primitive for the base type instead, but its clean implementation would require changing the way allocators are implemented to always allocate the bounds alongside the data, which may turn out to be delicate. This instead changes the compiler to synthesize a local Finalize_Address primitive in the problematic cases, which should be rare in practice, and also contains a fixlet for Find_Last_Init, which fails to get to the base type again in the indirect case and, therefore, mishandles array subtypes. gcc/ada/ * exp_ch7.adb (Attach_Object_To_Master_Node): Fix formatting. (Build_Finalizer.Process_Object_Declaration): Synthesize a local Finalize_Address primitive if the object's subtype is an array that has a constrained first subtype and is not this first subtype. * exp_util.adb (Find_Last_Init): Get again to the base type in the indirect case.
Diffstat (limited to 'gcc/expr.cc')
0 files changed, 0 insertions, 0 deletions