]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Finalization not performed for component of protected type
authorSteve Baird <baird@adacore.com>
Tue, 6 Jun 2023 19:44:00 +0000 (12:44 -0700)
committerMarc Poulhiès <poulhies@adacore.com>
Thu, 6 Jul 2023 11:36:09 +0000 (13:36 +0200)
commitfd4f48b37718748b39344129e70223a5d290c6eb
tree22adfaeac87dfe9805d5297896d78d84a23845be
parentdeebf06a1207bf7d84f4bebc462137d9436ee6dd
ada: Finalization not performed for component of protected type

In some cases involving a discriminated protected type with an array
component that is subject to a discriminant-dependent index constraint,
where the element type of the array requires finalization and the array
type has not yet been frozen at the point of the declaration of the protected
type, finalization of an object of the protected type may incorrectly omit
finalization of the array component. One case where this scenario can arise
is an instantiation of Ada.Containers.Bounded_Synchronized_Queues, passing in
an Element type that requires finalization.

gcc/ada/

* exp_ch7.adb (Make_Final_Call): Add assertion that if no
finalization call is generated, then the type of the object being
finalized does not require finalization.
* freeze.adb (Freeze_Entity): If freezing an already-frozen
subtype, do not assume that nothing needs to be done. In the case
of a frozen subtype of a non-frozen type or subtype (which is
possible), freeze the non-frozen entity.
gcc/ada/exp_ch7.adb
gcc/ada/freeze.adb