Files
Ronan Desplanques 3b9a2746b6 Add support for "finally" GNAT extension
For a description of the extension, see the GNAT reference manual.

An effort has been made to minimize the impact on parsing error recovery.

Basic benchmarking was performed and showed no observable performance
impact.
2025-12-16 10:33:33 +01:00

30 lines
710 B
Plaintext

pragma Extensions_Allowed (All_Extensions);
pragma Assertion_Policy (Check);
procedure Main is
My_Exception : exception;
Counter : Natural := 0;
begin
for J in 1 .. 2 loop
begin
-- In the first iteration of the loop, we exit the following block
-- normally, and in the second iteration, we exit it by raising an
-- exception. In both cases, the finally part is executed.
begin
if J = 2 then
raise My_Exception;
end if;
finally
Counter := Counter + 1;
end;
exception
when My_Exception =>
null;
end;
end loop;
pragma Assert (Counter = 2);
end Main;