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

Ada Rejects Exceptional Contracts on No_Raise Subprograms.

The Ada compiler now rejects the SPARK-specific `Exceptional_Cases` and `Exit_Cases` pragmas when used with `No_Raise` subprograms.

The Ada compiler now rejects the SPARK-specific exceptional contract pragmas Exceptional_Cases and Exit_Cases when they are incompatible with the No_Raise aspect. The No_Raise aspect, specific to GNAT, indicates that a subprogram will not raise any exceptions. The Analyze_Exit_Contract and Analyze_Pragma functions in sem_prag.adb have been updated to enforce this restriction.

In Details

This commit involves the interaction between SPARK contracts (Exceptional_Cases, Exit_Cases) and the GNAT-specific No_Raise aspect in Ada. The semantic analysis phase (sem_prag.adb) is modified to reject exceptional contracts on subprograms that are declared No_Raise, as these constructs are contradictory. SPARK contracts are used for formal verification, while No_Raise is a promise that no exceptions will be raised.

For Context

In Ada, exceptions are a mechanism for handling errors during program execution. SPARK is a subset of Ada designed for high-assurance software development, and it uses contracts to formally specify program behavior. This commit prevents the use of exception-related SPARK contracts on subprograms declared with the No_Raise aspect, which promises that the subprogram will not throw any exceptions. This ensures consistency and prevents potential errors in code that mixes SPARK and GNAT extensions.

Filed Under: adasparkexceptionscontracts