GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc/ada

Ada: Fix finalization not performed correctly with mutably tagged types

Corrects Ada finalization for mutably tagged types and optimizes boilerplate generation.

This commit addresses an issue where Ada finalization was not correctly performed for descendants of mutably tagged types that had controlled components. It also prevents the generation of unnecessary finalization boilerplate code for class-wide objects of regular tagged types. Additional fixes improve Might_Have_Tasks and Find_Type_Name.

In Details

GCC's Ada front-end had issues with finalization for mutably tagged types in gen_il-gen_gen_entities.adb, exp_ch5.adb, and exp_ch7.adb. This change ensures correct finalization when descendants have controlled components and optimizes by not generating finalization boilerplate for class-wide types with No_Controlled_Parts. It also refines logic in Might_Have_Tasks and Find_Type_Name.

For Context
mutably tagged type
In Ada, a tagged type whose tag can be changed at runtime.
controlled component
In Ada, a component of a record type that requires special handling for initialization, finalization, or adjustment, typically involving user-defined procedures.
class-wide type
In Ada, a type that represents objects of any type within a specific class of tagged types.
finalization
In Ada, the process of cleaning up resources or performing necessary actions when an object goes out of scope or is deallocated.
Filed Under: adacompilerbugfix