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

Error on legal No_Return subprogram with formals subject to Type_Invariant

The Ada compiler no longer incorrectly flags errors for `No_Return` subprograms with formals subject to `Type_Invariant` aspects.

The Ada compiler incorrectly reported an error for valid No_Return subprograms when their formals had a Type_Invariant aspect. This spurious error occurred due to the creation of a wrapper subprogram for invariant/postcondition checks, which interfered with the No_Return check. This commit prevents the generation of the wrapper subprogram for No_Return subprograms, as invariants and postconditions will never be executed in this case, thus resolving the false error.

In Details

The issue occurred in Sem_Ch6.Check_Returns when a No_Return subprogram also had formals with Type_Invariant aspects. Expand_Subprogram_Contract in contracts.adb now avoids calling Build_Subprogram_Contract_Wrapper for No_Return subprograms. Search context: Ada compiler No_Return Type_Invariant Sem_Ch6 Expand_Subprogram_Contract

For Context

In Ada, a No_Return subprogram indicates that the subprogram will never return to the caller. A Type_Invariant aspect specifies conditions that must always be true for a given type. This commit fixes a bug where the compiler would incorrectly flag an error if a No_Return subprogram had parameters whose types had invariants. The fix ensures that the compiler correctly handles these situations. Search context: Ada compiler No_Return Type_Invariant Sem_Ch6 Expand_Subprogram_Contract

Filed Under: adabugfixerror handling