Ada: Improve handling of Ghost => True/False for Abstract_State
Enhances handling of Ghost aspects for Abstract_State pragmas, adding error checks for invalid usage.
This commit improves the handling of Ghost => True/False for Abstract_State pragmas. It ensures that an Assertion_Level is assigned when Ghost => True is used, and it adds errors if Ghost => False is used within a ghost package, or if the expression used for Ghost is not static. These changes enhance the correctness and clarity of using ghost state in Ada code.
In Details
This commit modifies sem_prag.adb (Analyze_Abstract_State) to improve the handling of the Ghost aspect in Abstract_State pragmas. It ensures an Assertion_Level assignment for Ghost => True, and introduces error checks for invalid Ghost => False usage within ghost packages and non-static expressions.
For Context
In Ada, pragmas are instructions to the compiler. Abstract_State is a pragma used to define abstract data that represents the state of a program. The Ghost aspect indicates whether a variable exists only for specification and verification purposes, and is not part of the compiled code. This commit improves the handling of the Ghost aspect when used with Abstract_State, adding error checks to ensure it's used correctly. This helps developers write more robust and verifiable Ada code.