There are two issues in code expansion related to Ada.Finalization that aren’t properly handled in the presence of pragma Restriction (No_Exception_Propagation).
The expanded code attempts to catch any exception propagated during Finalize and record that it happened, and later, if there was a caught exception, raise Program_Error instead. Given No_Exception_Propagation, this fails because no exception could have been propagated from Finalize in the first place, so Exp_Ch7.Build_Object_Declarations detects that No_Exception_Propagation is in force and omits the creation of the temporary variable which would have recorded the propagation. The attached patch modifies the two compiler source files affected and adds a new test case. Patched 5.1.0 code, bootstrap and regression test on x86_64-apple-darwin13. The patches apply to trunk with minor offsets. gcc/ada/Changelog: 2015–6-14 Simon Wright <si...@pushface.org PR ada/66242 * exp_ch7.adb (Process_Transient_Objects): new constant Exceptions_OK. If exceptions aren't OK, build Fin_Block without wrapping the Stmts in an exception handler. At end, only Build_Raise_Statement if exceptions are OK. * exp_intr.adb (Expand_Unc_Deallocation): if exceptions aren't being propagated, build Final_Code without including any exception handler. Don't append a raise statement if exceptions aren't being propagated. gcc/testsuite/Changelog: 2015–6-14 Simon Wright <si...@pushface.org PR ada/66242 * gnat.dg/finalization.ad[sb]: new.
pr66242.diff
Description: Binary data