Corrects context checks for the Initialized attribute
This commit fixes an issue where the Ada `Initialized` attribute was incorrectly checked in ghost code contexts, preventing compile-time errors.
The Ada front end now correctly handles the Initialized attribute within ‘ghost code’ contexts. Previously, the compiler would attempt to apply checks meant for runtime code to these special compile-time sections, leading to errors. This fix ensures that the Initialized attribute can be used appropriately in ghost code without triggering erroneous policy and level checks.
In Details
The Ada Initialized attribute is a special-purpose attribute commonly used in formal verification and Contracts, often within 'ghost code' — code that exists only for verification purposes and is not compiled into the final executable. The ghost.adb unit contains logic for handling ghost code. Specifically, the Is_OK_Statement function checks the validity of statements within ghost contexts. This commit addresses a bug where Check_Ghost_Context.Is_OK_Statement was incorrectly applying general statement validity checks (like those for policies and levels) to usages of the Initialized…
For Context
In software development, especially for critical systems, developers sometimes write 'ghost code' that helps verify the correctness of their main program but isn't actually included in the final software. Ada, a programming language known for its reliability features, allows for this. The Initialized attribute is a special flag that can be used in this verification code to check if a variable has been given an initial value. This change in the GCC Ada compiler fixes an issue where the compiler was applying regular program rules to these special verification checks, causing errors. Now, developers can use the Initialized attribute in their ghost code without triggering incorrect compiler warnings or errors, making it easier to ensure their programs are properly initialized.