aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2024-10-24 07:44:13 +0200
committerMarc Poulhiès <dkm@gcc.gnu.org>2024-11-12 14:00:50 +0100
commitfa50a45ece189fc19054e5596c974aca82525278 (patch)
tree361d20f9013b93eeaf5b63fa09be38b951dcae14 /gcc/ada
parent0aeae8f645f087d455daf6bdc999eb2389bfc646 (diff)
downloadgcc-fa50a45ece189fc19054e5596c974aca82525278.zip
gcc-fa50a45ece189fc19054e5596c974aca82525278.tar.gz
gcc-fa50a45ece189fc19054e5596c974aca82525278.tar.bz2
ada: Flatten Is_Build_In_Place_Aggregate_Return predicate
The predicate is passed an aggregate node and goes up its parent chain, but that's unnecessary because Convert_To_Assignments has already done so in the case of a record aggregate and Expand_Array_Aggregate does not fully support intermediate conditional expressions yet. gcc/ada/ChangeLog: * exp_aggr.adb (Is_Build_In_Place_Aggregate_Return): Directly test the node and remove dead code for extended return statements.
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/exp_aggr.adb35
1 files changed, 10 insertions, 25 deletions
diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb
index ed50d94..8231e40 100644
--- a/gcc/ada/exp_aggr.adb
+++ b/gcc/ada/exp_aggr.adb
@@ -166,11 +166,12 @@ package body Exp_Aggr is
------------------------------------------------------
function Is_Build_In_Place_Aggregate_Return (N : Node_Id) return Boolean;
- -- True if N is an aggregate (possibly qualified or a dependent expression
- -- of a conditional expression, and possibly recursively so) that needs to
- -- be built-in-place in the return object. Such qualified and conditional
- -- expressions are transparent for this purpose because an enclosing return
- -- is propagated resp. distributed into these expressions by the expander.
+ -- Return True if N is a simple return whose expression needs to be built
+ -- in place in the return object, assuming the expression is an aggregate,
+ -- possibly qualified or a dependent expression of a conditional expression
+ -- (and possibly recursively). Such qualified and conditional expressions
+ -- are transparent for this purpose since an enclosing return is propagated
+ -- resp. distributed into these expressions by the expander.
function Build_Record_Aggr_Code
(N : Node_Id;
@@ -4307,7 +4308,7 @@ package body Exp_Aggr is
-- finalization of the return object (which is built in place
-- within the caller's scope).
- or else Is_Build_In_Place_Aggregate_Return (N)
+ or else Is_Build_In_Place_Aggregate_Return (Parent_Node)
then
Node := N;
@@ -6193,7 +6194,7 @@ package body Exp_Aggr is
(Defining_Identifier (Parent_Node))))
or else (Parent_Kind = N_Assignment_Statement
and then Inside_Init_Proc)
- or else Is_Build_In_Place_Aggregate_Return (N)
+ or else Is_Build_In_Place_Aggregate_Return (Parent_Node)
then
Set_Expansion_Delayed (N, not Static_Array_Aggregate (N));
return;
@@ -8892,29 +8893,13 @@ package body Exp_Aggr is
function Is_Build_In_Place_Aggregate_Return (N : Node_Id) return Boolean is
F : Entity_Id;
- P : Node_Id;
begin
- P := Parent (N);
- while Nkind (P) in N_Case_Expression
- | N_Case_Expression_Alternative
- | N_If_Expression
- | N_Qualified_Expression
- loop
- P := Parent (P);
- end loop;
-
- if Nkind (P) = N_Simple_Return_Statement then
- null;
-
- elsif Nkind (Parent (P)) = N_Extended_Return_Statement then
- P := Parent (P);
-
- else
+ if Nkind (N) /= N_Simple_Return_Statement then
return False;
end if;
- F := Return_Applies_To (Return_Statement_Entity (P));
+ F := Return_Applies_To (Return_Statement_Entity (N));
-- For a build-in-place function, all the returns are done in place
-- by definition. We also return aggregates in place in other cases