aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@adacore.com>2021-03-11 11:00:04 -0500
committerPierre-Marie de Rodat <derodat@adacore.com>2021-06-17 10:32:15 -0400
commit5f900b589c83b789329a0e99ddbe627507703e5e (patch)
tree68a3673a891716785d1a7fd0a0907ba2e38e0a81
parentb4d46ee9a15b83552134476e9c0f691df1bfa123 (diff)
downloadgcc-5f900b589c83b789329a0e99ddbe627507703e5e.zip
gcc-5f900b589c83b789329a0e99ddbe627507703e5e.tar.gz
gcc-5f900b589c83b789329a0e99ddbe627507703e5e.tar.bz2
[Ada] Missing finalization on nested expression with action
gcc/ada/ * exp_ch4.adb (Expand_N_Expression_With_Actions.Process_Action): Do not abandon processing on a nested N_Expression_With_Actions or N_Loop_Statement, otherwise we may miss some transient declarations.
-rw-r--r--gcc/ada/exp_ch4.adb15
1 files changed, 7 insertions, 8 deletions
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index 5b3a116..4436557 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -5780,15 +5780,14 @@ package body Exp_Ch4 is
-- Avoid processing temporary function results multiple times when
-- dealing with nested expression_with_actions.
+ -- 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) = N_Expression_With_Actions then
- return Abandon;
-
- -- Do not process temporary function results in loops. This is done
- -- by Expand_N_Loop_Statement and Build_Finalizer.
-
- elsif Nkind (Act) = N_Loop_Statement then
- return Abandon;
+ elsif Nkind (Act) in N_Expression_With_Actions | N_Loop_Statement then
+ return Skip;
end if;
return OK;