GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
ada

Ada legality check for tagged and untagged types is now factorized.

Combines duplicate legality checks for tagged and untagged types in Ada, improving code consistency and error reporting.

This patch refactors the Ada legality check for tagged and untagged types, which previously had separate implementations with distinct error messages. By factorizing these checks into a single rule as defined by the Ada reference manual (7.3), the compiler maintains better consistency and provides a unified error reporting mechanism for this legality rule.

In Details

The Ada standard defines a legality rule in paragraph 7.3 that applies to both tagged and untagged types. Previously, GCC's Ada front-end implemented this check separately in sem_ch3.adb (Process_Full_View) for tagged and untagged cases, leading to duplicated code and potentially different error messages. This patch removes the bypass for the tagged case and factorizes the check, ensuring a single, consistent implementation and error reporting for this rule.

For Context
tagged type
An Ada type that has a tag, enabling dynamic dispatch and polymorphism. It forms the basis for hierarchical type extensions.
untagged type
An Ada type that does not have a tag and therefore does not support dynamic dispatch. Examples include simple scalar types and record types without special extensions.
legality check
A compiler check to ensure that a program adheres to the language's rules and constraints, beyond basic syntax, to prevent invalid or erroneous constructs.
factorize
In software development, to combine duplicate code or logic into a single, reusable unit to improve maintainability and reduce redundancy.
Filed Under: adarefactoringcompiler-frontend