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

Implement SPARK RM 6.9 (23) for ghost code in Ada

Implements a rule for ghost code in SPARK Ada related to user-defined equality operations on record types.

This commit implements rule 23 from SPARK Reference Manual 6.9, which concerns ghost code in Ada. The rule states that a user-defined primitive equality operation on a non-ghost record type must not be ghost, unless the record type has only limited views. Additionally, a user-defined primitive equality operation on a ghost record type must have a matching assertion level. This change ensures the correct usage of ghost code in SPARK Ada for equality operations.

In Details

The commit introduces Check_Ghost_Equality_Op in ghost.adb and ghost.ads, and integrates it into Valid_Operator_Definition in sem_ch6.adb. This enforces the SPARK RM 6.9 (23) rule regarding ghost equality operations on record types, considering limited views and assertion levels.

For Context

SPARK is a formally verifiable subset of Ada, used for high-integrity software development. "Ghost code" refers to code that is used for specification and verification but is not actually executed in the final program. This commit implements a rule related to how equality operations are defined for record types (like structs) when using ghost code, ensuring consistency between the ghost and non-ghost parts of the program.

Filed Under: adaSPARKghost codeverification