aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_res.adb
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2022-12-02 10:55:49 +0100
committerMarc Poulhiès <poulhies@adacore.com>2022-12-06 14:58:48 +0100
commitea588d41f39428b0c3b02f016353dceb1aaaaa39 (patch)
treece91f5abdcd15583a7e4e5f4ed70e44022c10d07 /gcc/ada/sem_res.adb
parenta444c05623faa2b6bd1bbc8f7908b8ea3d83b475 (diff)
downloadgcc-ea588d41f39428b0c3b02f016353dceb1aaaaa39.zip
gcc-ea588d41f39428b0c3b02f016353dceb1aaaaa39.tar.gz
gcc-ea588d41f39428b0c3b02f016353dceb1aaaaa39.tar.bz2
ada: Elide the copy in extended returns for nonlimited by-reference types
This implements elision of the copy operation for extended return statements in the case of nonlimited by-reference types (the copy operation is already elided for limited types by the front-end and nonlimited non-by-reference types by the code generator), which comprise controlled and tagged types. The implementation partly reuses the machinery implemented for limited types (the build-in-place machinery) to allocate the return object directly on the primary or the secondary stack, depending on whether the result type of the function is constrained or not. This requires further special-casing for the allocators generated by this machinery as well as an adjustment to the implementation of a specific case of string concatenation. gcc/ada/ * einfo.ads (Actual_Subtype): Document additional usage. * exp_aggr.adb (Expand_Array_Aggregate): Replace test on Is_Build_In_Place_Return_Object with Is_Special_Return_Object. * exp_ch3.adb (Expand_N_Object_Declaration): Factor out parts of the processing done for build-in-place return objects and reuse them to implement a similar processing for specific return objects. * exp_ch4.adb (Expand_Allocator_Expression): Do not generate a tag assignment or an adjustment if the allocator was made for a special return object. (Expand_Concatenate): If the result is allocated on the secondary stack, use an unconstrained allocation. * exp_ch6.ads (Apply_CW_Accessibility_Check): New declaration. (Is_By_Reference_Return_Object): Likewise. (Is_Secondary_Stack_Return_Object): Likewise. (Is_Special_Return_Object): Likewise. * exp_ch6.adb (Expand_Ctrl_Function_Call): Do not bail out for the expression in the declaration of a special return object. (Expand_N_Extended_Return_Statement): Add missing guard and move the class-wide accessibility check to Expand_N_Object_Declaration. (Expand_Simple_Function_Return): Delete obsolete commentary. Skip the special processing for types that require finalization or are returned on the secondary stack if the return originally comes from an extended return statement. Add missing Constant_Present. (Is_By_Reference_Return_Object): New predicate. (Is_Secondary_Stack_Return_Object): Likewise. (Is_Special_Return_Object): Likewise. * exp_util.adb (Is_Related_To_Func_Return): Also return true if the parent of the expression is the renaming declaration generated for the expansion of a return object. * gen_il-fields.ads (Opt_Field_Enum): Replace Alloc_For_BIP_Return with For_Special_Return_Object. * gen_il-gen-gen_nodes.adb (N_Allocator): Likewise. * gen_il-internals.adb (Image): Remove Alloc_For_BIP_Return. * sem_ch3.adb (Check_Return_Subtype_Indication): New procedure moved from sem_ch6.adb. (Analyze_Object_Declaration): Call it on a return object. * sem_ch4.adb: Add with and use clauses for Rtsfind. (Analyze_Allocator): Test For_Special_Return_Object to skip checks for allocators made for special return objects. Do not report restriction violations for the return stack pool. * sem_ch5.adb (Analyze_Assignment.Set_Assignment_Type): Return the Actual_Subtype for return objects that live on the secondary stack. * sem_ch6.adb (Check_Return_Subtype_Indication): Move procedure to sem_ch3.adb. (Analyze_Function_Return): Do not call above procedure. * sem_res.adb (Resolve_Allocator): Replace Alloc_For_BIP_Return with For_Special_Return_Object. * sinfo.ads: Likewise. * treepr.adb (Image): Remove Alloc_For_BIP_Return. * gcc-interface/trans.cc (gnat_to_gnu): Do not convert to the result type in the unconstrained array type case if the parent is a simple return statement.
Diffstat (limited to 'gcc/ada/sem_res.adb')
-rw-r--r--gcc/ada/sem_res.adb2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index 4bbec65..b54ed93 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -5622,7 +5622,7 @@ package body Sem_Res is
-- caller does use an allocator, it will be caught at the call site.
if No_Pool_Assigned (Typ)
- and then not Alloc_For_BIP_Return (N)
+ and then not For_Special_Return_Object (N)
then
Error_Msg_N ("allocation from empty storage pool!", N);