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

The Ada front end fixes assertion error in subunit attribute references

The Ada front end now correctly handles attribute references within separate subunits, resolving a compiler `Assertion_Error`.

This commit resolves a compiler Assertion_Error that occurred when an attribute reference was used within an Ada subunit. The issue arose because the compiler incorrectly assumed a subunit subprogram body lacked an enclosing declaration list, leading it down an incorrect code path. The fix in exp_attr.adb ensures that the subunit case is properly identified, preventing the assertion failure and allowing correct compilation of attribute references in separate subunits.

In Details

The gcc/ada subsystem handles the Ada front end for the GCC compiler. This specific commit fixes a compiler Assertion_Error in exp_attr.adb, which is responsible for expanding attributes (e.g., T'Size) in Ada code. The underlying problem was a misidentification of the context for attribute references within 'subunits' (separately compiled bodies of subprograms defined in a parent unit). The compiler incorrectly treated a subunit subprogram body as if it had no enclosing declaration list, leading to a logical error in Build_And_Insert_Type_Attr_Subp. The fix ensures that the compiler…

For Context

The Ada front end is the part of the GCC compiler that understands Ada code. In Ada, a 'subunit' is a way to break up large program units into smaller, separately compiled pieces. This commit fixes a bug in the compiler that caused it to crash with an Assertion_Error when you tried to use an 'attribute reference' (like asking for the size of a type, e.g., MyType'Size) inside one of these subunits. The problem was that the compiler got confused about the structure of subunits; it mistakenly thought a subunit didn't have a list of declarations around it, which led it to try the wrong way to process the attribute. The fix in exp_attr.adb (a file related to handling these attributes) teaches the compiler to correctly recognize when it's dealing with a subunit, thus avoiding the internal error and allowing such code to compile successfully.

Filed Under: adabugfixcompiler-internals