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

Ada: Improve machinery for generating predicate checks

This commit improves the code that generates predicate checks in Ada, adding support for incomplete types and factoring out common code.

This commit enhances the machinery used for generating predicate checks in Ada. It introduces new subprograms Is_Fully_Initialized_Constrained_Array, Is_Fully_Initialized_Record_Type, and Is_Partially_Initialized_Record_Type to factorize code and add missing support for incomplete types. These improvements make the code more maintainable and ensure that predicate checks are correctly generated for a wider range of types.

In Details

The changes involve refactoring and extending the functionality of sem_util.adb and sem_util.ads. The commit moves Is_Fully_Initialized_Variant inside Is_Fully_Initialized_Type and introduces new subprograms to handle constrained arrays and record types. Additionally, the Is_Partially_Initialized_Type subprogram is updated to include a new formal parameter for predicate checks. sem_warn.adb and sem_ch3.adb are also updated to use the new machinery.

For Context

Predicates are conditions that must be true for a variable or type to be considered valid in Ada. This commit improves the internal mechanisms of the compiler responsible for generating checks that enforce these predicates. By adding support for incomplete types and reorganizing the code, the compiler can more reliably ensure that variables and types satisfy their defined predicates, leading to more robust and predictable programs.

Filed Under: adapredicate checksrefactorincomplete types