]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Small cleanup about allocators and aggregates
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 14 Feb 2024 00:22:49 +0000 (01:22 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 14 May 2024 08:19:57 +0000 (10:19 +0200)
commit08039257610508b153d13b6cab1f252297d143a9
tree858f2bfab72b5e69b667ae9c8ab35b79e8306793
parentad510c7c8b72cfe43ec0c0c94d650cdff91cc6a6
ada: Small cleanup about allocators and aggregates

This eliminates a few oddities present in the expander for allocators and
aggregates present in allocators:

  - Convert_Array_Aggr_In_Allocator takes both a Decl and Alloc parameters,
    and inserts new code before Alloc for records and after Decl for arrays
    through Convert_Array_Aggr_In_Allocator.  Now, for the 3 (duplicated)
    calls to the procedure, that's the same place.  It also creates a new
    list that it does not use in most cases.

  - Expand_Allocator_Expression uses the same code sequence in 3 places
    when the expression is an aggregate to build in place.

  - Build_Allocate_Deallocate_Proc takes an Is_Allocate parameter that is
    entirely determined by the N parameter: if N is an allocator, it must
    be true; if N is a free statement, it must be false.  Barring that,
    the procedure either raises an assertion or Program_Error.  It also
    contains useless pattern matching code in the second part.

No functional changes.

gcc/ada/

* exp_aggr.ads (Convert_Aggr_In_Allocator): Rename Alloc into N,
replace Decl with Temp and adjust description.
(Convert_Aggr_In_Object_Decl): Alphabetize.
(Is_Delayed_Aggregate): Likewise.
* exp_aggr.adb (Convert_Aggr_In_Allocator): Rename Alloc into N
and replace Decl with Temp.  Allocate a list only when neeeded.
(Convert_Array_Aggr_In_Allocator): Replace N with Decl and insert
new code before it.
* exp_ch4.adb (Build_Aggregate_In_Place): New procedure nested in
Expand_Allocator_Expression.
(Expand_Allocator_Expression): Call it to build aggregates in place.
Remove second parameter in calls to Build_Allocate_Deallocate_Proc.
(Expand_N_Allocator): Likewise.
* exp_ch13.adb (Expand_N_Free_Statement): Likewise.
* exp_util.ads (Build_Allocate_Deallocate_Proc): Remove Is_Allocate
parameter.
* exp_util.adb (Build_Allocate_Deallocate_Proc): Remove Is_Allocate
parameter and replace it with local variable of same name.  Delete
useless pattern matching.
gcc/ada/exp_aggr.adb
gcc/ada/exp_aggr.ads
gcc/ada/exp_ch13.adb
gcc/ada/exp_ch4.adb
gcc/ada/exp_util.adb
gcc/ada/exp_util.ads