ada: Fix missing finalization for aggregates nested in conditional expressions
commit985d6045f66281bd3783523360375431ee343b08
authorEric Botcazou <ebotcazou@adacore.com>
Sun, 14 May 2023 09:49:09 +0000 (14 11:49 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Thu, 15 Jun 2023 07:59:36 +0000 (15 09:59 +0200)
tree3b2bb55386beda700e1ad8406f93d3591325fd62
parentb36be75b29d7fc5c6ab3c48229f9521ae91c6a2c
ada: Fix missing finalization for aggregates nested in conditional expressions

The finalization actions for the components of the aggregates are blocked
by Expand_Ctrl_Function_Call, which sets Is_Ignored_Transient on all the
temporaries generated from within a conditional expression whatever the
intermediate constructs.  Now aggregates and their expansion in the form
of block and loop statements are "impenetrable" as far as temporaries are
concerned, i.e. the lifetime of temporaries generated within them does
not extend beyond them, so their finalization must not be blocked there.

gcc/ada/

* exp_util.ads (Within_Case_Or_If_Expression): Adjust description.
* exp_util.adb (Find_Hook_Context): Stop the search for the topmost
conditional expression, if within one, at contexts where temporaries
may be contained.
(Within_Case_Or_If_Expression): Return false upon first encoutering
contexts where temporaries may be contained.
gcc/ada/exp_util.adb
gcc/ada/exp_util.ads