summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2025-11-12 16:13:03 +0100
committerMarc Poulhiès <dkm@gcc.gnu.org>2025-11-21 09:29:37 +0100
commit56722ed86ead6226148f7fc73fbf5691be2e37b2 (patch)
treea31ecc7bbb09a39b7b67aec83032a0cb94af8788
parent57d3933a8705bcea91d8a7189d7d5d5edce14524 (diff)
ada: Remove obsolete call to Establish_Transient_Scope
There is a preceding call to Establish_Transient_Scope in the procedure for the cases where it is required, and we no longer build the aggregate on the stack before copying it to the heap for an allocator. gcc/ada/ChangeLog: * exp_aggr.adb (Expand_Array_Aggregate): Remove obsolete call to Establish_Transient_Scope for an allocator in a loop. * exp_ch7.adb (Establish_Transient_Scope): Adjust description.
-rw-r--r--gcc/ada/exp_aggr.adb13
-rw-r--r--gcc/ada/exp_ch7.adb5
2 files changed, 4 insertions, 14 deletions
diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb
index 6b6b0aba4b0..51fbdb8e1e9 100644
--- a/gcc/ada/exp_aggr.adb
+++ b/gcc/ada/exp_aggr.adb
@@ -6400,21 +6400,10 @@ package body Exp_Aggr is
Object_Definition => New_Occurrence_Of (Typ, Loc));
Set_No_Initialization (Tmp_Decl, True);
- -- If we are within a loop, the temporary will be pushed on the
- -- stack at each iteration. If the aggregate is the expression
- -- for an allocator, it will be immediately copied to the heap
- -- and can be reclaimed at once. We create a transient scope
- -- around the aggregate for this purpose.
-
- if Ekind (Current_Scope) = E_Loop
- and then Nkind (Parent_Node) = N_Allocator
- then
- Establish_Transient_Scope (N, Manage_Sec_Stack => False);
-
-- If the parent is an assignment for which no controlled actions
-- should take place, prevent the temporary from being finalized.
- elsif Nkind (Parent_Node) = N_Assignment_Statement
+ if Nkind (Parent_Node) = N_Assignment_Statement
and then No_Ctrl_Actions (Parent_Node)
then
Mutate_Ekind (Tmp, E_Variable);
diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb
index 8c661900b06..c170c23451d 100644
--- a/gcc/ada/exp_ch7.adb
+++ b/gcc/ada/exp_ch7.adb
@@ -4276,8 +4276,9 @@ package body Exp_Ch7 is
-- Establish_Transient_Scope --
-------------------------------
- -- This procedure is called each time a transient block has to be inserted
- -- that is to say for each call to a function with unconstrained or tagged
+ -- This procedure is called when a transient scope has to be inserted in
+ -- the tree to manage the lifetime of temporaries created for a construct,
+ -- most notably for calls to functions with a controlled or unconstrained
-- result. It creates a new scope on the scope stack in order to enclose
-- all transient variables generated.