diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2024-01-21 00:29:45 +0100 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2024-05-13 10:03:28 +0200 |
commit | 8d6c7fccd04944804f7ca0f7ba7b4a3a7f1082dd (patch) | |
tree | 20cea0a60d5d967d4da48fd01636ea231b34ed26 /gcc/ada/exp_ch6.ads | |
parent | 8e76c189f10ee3b766cfde6b1ccb59b49342b0e5 (diff) | |
download | gcc-8d6c7fccd04944804f7ca0f7ba7b4a3a7f1082dd.zip gcc-8d6c7fccd04944804f7ca0f7ba7b4a3a7f1082dd.tar.gz gcc-8d6c7fccd04944804f7ca0f7ba7b4a3a7f1082dd.tar.bz2 |
ada: Restore fix for controlled dynamic allocation with BIP function call
The resolution made some time ago had been that a dynamic allocation for
a limited type that needs finalization with a function call as expression
always needs to be done in the called function, even if the limited type
has a known size. But the fix implementing this resolution was dropped
inadvertently at some point.
The change also contains a small tweak for Expand_N_Object_Declaration
and a small related cleanup in the finalization machinery.
gcc/ada/
* exp_ch3.adb (Expand_N_Object_Declaration): In the case of a
return object of a BIP function that needs finalization, save
the assignment statement made to initialize it, if any.
* exp_ch6.ads (BIP_Formal_Kind): Adjust description.
* exp_ch6.adb (Make_Build_In_Place_Call_In_Allocator): Make a
couple of adjustments to the commentary.
(Needs_BIP_Alloc_Form): Also return true if the function needs
a BIP_Finalization_Master parameter.
* exp_ch7.adb (Build_BIP_Cleanup_Stmts): Remove now always true
test on Needs_BIP_Alloc_Form.
(Attach_Object_To_Master_Node): Remove duplication in comment.
Diffstat (limited to 'gcc/ada/exp_ch6.ads')
-rw-r--r-- | gcc/ada/exp_ch6.ads | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/gcc/ada/exp_ch6.ads b/gcc/ada/exp_ch6.ads index 12a9ce3..79e4120 100644 --- a/gcc/ada/exp_ch6.ads +++ b/gcc/ada/exp_ch6.ads @@ -47,8 +47,8 @@ package Exp_Ch6 is -- nodes (e.g. the filling of the corresponding Dispatch Table for -- Primitive Operations) - -- The following type defines the various forms of allocation used for the - -- results of build-in-place function calls. + -- Ada 2005 (AI-318-02): The following type defines the various forms of + -- allocation used for the result of build-in-place function calls. type BIP_Allocation_Form is (Unspecified, @@ -57,22 +57,24 @@ package Exp_Ch6 is Global_Heap, User_Storage_Pool); - type BIP_Formal_Kind is -- Ada 2005 (AI-318-02): This type defines the kinds of implicit extra -- formals created for build-in-place functions. The order of these -- enumeration literals matches the order in which the formals are -- declared. See Sem_Ch6.Create_Extra_Formals. + type BIP_Formal_Kind is (BIP_Alloc_Form, - -- Present if result subtype is unconstrained or tagged. Indicates - -- whether the return object is allocated by the caller or callee, and - -- if the callee, whether to use the secondary stack or the heap. See - -- Create_Extra_Formals. + -- Present if result subtype is returned on the secondary stack or is + -- tagged: in this case, this indicates whether the return object is + -- allocated by the caller or callee, and if the callee, whether to + -- use the secondary stack, the global heap or a storage pool. Also + -- present if result type needs finalization. BIP_Storage_Pool, - -- Present if result subtype is unconstrained or tagged. If - -- BIP_Alloc_Form = User_Storage_Pool, this is a pointer to the pool - -- (of type access to Root_Storage_Pool'Class). Otherwise null. + -- Present if result subtype is returned on the secondary stack or is + -- tagged: in this case, if BIP_Alloc_Form = User_Storage_Pool, this + -- is a pointer to the pool (of type Root_Storage_Pool_Ptr); otherwise + -- this is null. Also present if result type needs finalization. BIP_Finalization_Master, -- Present if result type needs finalization. Pointer to caller's |