GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
ada

Ada: Improve freezing of tagged types by expression functions in nested packages

Delays the generation of stand-alone expression functions to fix freezing issues with tagged types in nested packages.

This commit addresses a long-standing issue in the Ada compiler related to how expression functions interact with the freezing of tagged types, especially within nested packages. The compiler’s freezing model requires types to be frozen before code generation. To address inconsistencies with Ada 95’s freezing model, the compiler now inserts the generated body of stand-alone expression functions at the next freezing point, which resolves issues in nested packages. This approach involves treating the generated body as an inlined body, requiring a more comprehensive implementation of the freezing rules for expression functions.

In Details

This commit overhauls the freezing mechanism for expression functions, particularly concerning their interaction with tagged types, by modifying/deleting functions in contracts.adb, exp_ch3.adb, exp_ch6.adb, and freeze.ads. The core change is to delay the insertion of generated bodies for stand-alone expression functions until the next freezing point, effectively treating them as inlined. This addresses inconsistencies in freezing behavior within nested packages, where the analysis and resolution of the body must yield identical results to the preanalysis performed on the expression.

For Context

In Ada, types need to be 'frozen' before code can be generated. Freezing means the characteristics of a type are fixed and cannot be changed. Expression functions, a feature in Ada 2012, can affect when types are frozen. This commit fixes an issue where the freezing of tagged types (types used in object-oriented programming) by expression functions was inconsistent, especially in nested packages. The fix involves changing when the code for these expression functions is generated, ensuring that types are frozen at the correct time, leading to more reliable code generation.

Filed Under: adacompilerfreezingtagged typesexpression functions