Enhances error message for incomplete record definitions
This commit improves error reporting when an Ada record is frozen with incompletely defined component types.
The GCC Ada compiler now provides a more precise error message when a record type is frozen prematurely and contains incompletely defined component types. Previously, the error message might misleadingly complain about a ‘private component.’ The updated message directly indicates that the component type is not fully defined, aligning with ARM 3.11.1 (8) and offering clearer guidance to developers on how to resolve the issue.
In Details
In Ada, a record type must be 'frozen' (its definition finalized) before certain operations, which requires all its component types to be fully defined. The freeze.adb unit handles type freezing. This commit modifies Check_And_Freeze_Type to use a new utility function, Incompletely_Defined (in sem_util.adb and sem_util.ads), to recursively check for incomplete definitions within a record's components. The previous error message for private components was often a red herring for the actual problem of an incompletely defined type. The improved error message now accurately pinpoints th…
For Context
Imagine you're building a complex data structure (a 'record' in Ada) out of smaller pieces (its 'components'). In Ada, there's a point where the compiler 'freezes' the definition of your record, meaning no more changes can be made to its structure. For this to happen correctly, all the component pieces must also be fully defined. Previously, if a component wasn't entirely defined when the record was frozen, the compiler's error message might have been confusing, suggesting the component was 'private' when the real issue was its incomplete definition. This change makes the compiler's error messages much clearer, directly telling you that a component type isn't fully defined. This helps you understand and fix your code more quickly, as the error message accurately describes the problem.