diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2024-10-21 10:55:28 +0200 |
---|---|---|
committer | Marc Poulhiès <dkm@gcc.gnu.org> | 2024-11-12 14:00:46 +0100 |
commit | b861785242450c8711aae6394751a75eadc4a0a9 (patch) | |
tree | 403fbaf169e6bf2d5e7c55a11dae3adf35a5b354 /gcc/ada/raise-gcc.c | |
parent | 0b58c0ec6e9686e9645e269e020e77efbe30ab79 (diff) | |
download | gcc-b861785242450c8711aae6394751a75eadc4a0a9.zip gcc-b861785242450c8711aae6394751a75eadc4a0a9.tar.gz gcc-b861785242450c8711aae6394751a75eadc4a0a9.tar.bz2 |
ada: Elide the copy in aggregate returns for nonlimited types
This implements elision of the copy operation for aggregate returns, i.e.
simple return statements whose expression is an aggregate, in the case of
nonlimited by-reference types (the copy operation is already elided for
limited types), which comprise controlled and tagged types. This is the
copy operation in the called function, that is to say the copy from the
anonymous object built for the aggregate to the anonymous return object.
The implementation simply extends that of limited types, which rewrites
the simple return statement as an extended return statement internally
and then leverages the built-in-place implementation of return objects
for these statements.
gcc/ada/ChangeLog:
* exp_aggr.adb (Is_Build_In_Place_Aggregate_Return): Also return
True for functions returning on the secondary stack or returning
a by-reference type if the back end exposes its return slot.
(Expand_Array_Aggregate): Call Is_Build_In_Place_Aggregate_Return
to spot aggregates to be built in place.
* exp_ch3.adb (Make_Allocator_For_Return): Add missing condition
in assertion pragma deduced from Expand_Subtype_From_Expr.
* exp_ch6.adb (Expand_Simple_Function_Return): Rewrite the statement
as an extended return statement if the expression is an aggregate
whose expansion is delayed. Properly relocate the expression in
this case.
* sem_ch6.adb: Add clauses for Exp_Aggr.
(Analyze_Function_Return): Do not apply the predicate check to an
aggregate whose expansion is delayed. Extended the processing of
case expressions to all conditional expressions.
Diffstat (limited to 'gcc/ada/raise-gcc.c')
0 files changed, 0 insertions, 0 deletions