Fix crash when using pragma Ignore_Pragma in SPARK mode.
The compiler no longer crashes when using `pragma Ignore_Pragma` in SPARK mode due to improved handling of protected bodies.
This commit fixes a bug in the expansion of protected bodies that caused a crash when using pragma Ignore_Pragma in SPARK mode. The fix consolidates the cases that copy Op_Body, which is usually a protected subprogram declaration or body, and removes the unnecessary raise Program_Error. This change makes the code more robust and DRY, preventing the crash and improving the handling of protected bodies in SPARK mode.
In Details
The bug occurred during the expansion of protected bodies in exp_ch9.adb. The original code raised a Program_Error when Op_Body was a null statement, which can happen when using pragma Ignore_Pragma (SPARK_Mode). This commit removes the raise Program_Error and consolidates the cases that simply copy Op_Body, making the code more general and preventing the crash. This fix is relevant to developers using SPARK mode with pragma Ignore_Pragma.
For Context
The SPARK subset of Ada is designed for high-assurance software development, focusing on formal verification and static analysis. Pragmas are special directives that provide instructions to the compiler. This commit fixes a bug that occurred when using a specific pragma (Ignore_Pragma) within SPARK mode, preventing the compiler from crashing. The issue arose during the expansion of protected bodies, which are a mechanism for managing concurrent access to shared data. This ensures more robust compilation when using SPARK.