Skip to content

Commit

Permalink
ada: Fix double finalization in conditional exit statement
Browse files Browse the repository at this point in the history
The temporary is first finalized through its enclosing block.

gcc/ada/

	* exp_ch4.adb (Expand_N_Expression_With_Actions.Process_Action): Do
	not look into nested blocks.

Tested on x86_64-pc-linux-gnu, committed on master.
  • Loading branch information
Eric Botcazou authored and ouuleilei-bot committed May 22, 2023
1 parent c2d62cd commit 917d7cb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions gcc/ada/exp_ch4.adb
Original file line number Diff line number Diff line change
Expand Up @@ -5651,14 +5651,17 @@ package body Exp_Ch4 is
return Skip;

-- Avoid processing temporary function results multiple times when
-- dealing with nested expression_with_actions.
-- dealing with nested expression_with_actions or nested blocks.
-- Similarly, do not process temporary function results in loops.
-- This is done by Expand_N_Loop_Statement and Build_Finalizer.
-- Note that we used to wrongly return Abandon instead of Skip here:
-- this is wrong since it means that we were ignoring lots of
-- relevant subsequent statements.

elsif Nkind (Act) in N_Expression_With_Actions | N_Loop_Statement then
elsif Nkind (Act) in N_Expression_With_Actions
| N_Block_Statement
| N_Loop_Statement
then
return Skip;
end if;

Expand Down

0 comments on commit 917d7cb

Please sign in to comment.