-- Set the Expansion_Delayed flag in the cases where the transformation
-- will be done top down from above.
- Parent_Node := Unconditional_Parent (N);
+ Parent_Node := Unqualified_Unconditional_Parent (N);
if
-- Internal aggregates (transformed when expanding the parent),
-- Set the Expansion_Delayed flag in the cases where the transformation
-- will be done top down from above.
- Parent_Node := Unconditional_Parent (N);
+ Parent_Node := Unqualified_Unconditional_Parent (N);
if
-- Internal aggregates (transformed when expanding the parent),
if not Expansion_Delayed (N) then
declare
- Uncond_Par : constant Node_Id := Unconditional_Parent (N);
+ Uncond_Par : constant Node_Id :=
+ Unqualified_Unconditional_Parent (N);
begin
if Nkind (Uncond_Par) = N_Simple_Return_Statement
or else Is_Optimizable_Declaration (Uncond_Par)
if not Expansion_Delayed (N) then
declare
- Uncond_Par : constant Node_Id := Unconditional_Parent (N);
+ Uncond_Par : constant Node_Id :=
+ Unqualified_Unconditional_Parent (N);
begin
if Nkind (Uncond_Par) = N_Simple_Return_Statement
or else Is_Optimizable_Declaration (Uncond_Par)
is
Par : constant Node_Id := Parent (N);
Uncond_Par : constant Node_Id := Unconditional_Parent (N);
+ -- Beware that a qualified expression around a function call cannot be
+ -- considered as transparent (like around an aggregate) because it may
+ -- cause a temporary to be created.
begin
-- Optimization: if the returned value is returned again, then no need
-- to copy/readjust/finalize, we can just pass the value through (see
- -- Expand_N_Simple_Return_Statement), and thus no attachment is needed.
+ -- Expand_Simple_Function_Return), and thus no attachment is needed.
-- Note that simple return statements are distributed into conditional
-- expressions, but we may be invoked before this distribution is done.
Node : Node_Id := N;
Parent_Node : Node_Id := Parent (Node);
+ begin
+ loop
+ case Nkind (Parent_Node) is
+ when N_Case_Expression_Alternative =>
+ null;
+
+ when N_Case_Expression =>
+ exit when Node = Expression (Parent_Node);
+
+ when N_If_Expression =>
+ exit when Node = First (Expressions (Parent_Node));
+
+ when others =>
+ exit;
+ end case;
+
+ Node := Parent_Node;
+ Parent_Node := Parent (Node);
+ end loop;
+
+ return Parent_Node;
+ end Unconditional_Parent;
+
+ --------------------------------------
+ -- Unqualified_Unconditional_Parent --
+ --------------------------------------
+
+ function Unqualified_Unconditional_Parent (N : Node_Id) return Node_Id is
+ Node : Node_Id := N;
+ Parent_Node : Node_Id := Parent (Node);
+
begin
loop
case Nkind (Parent_Node) is
end loop;
return Parent_Node;
- end Unconditional_Parent;
+ end Unqualified_Unconditional_Parent;
-------------------------------
-- Update_Primitives_Mapping --
function Unconditional_Parent (N : Node_Id) return Node_Id;
-- Return the first parent of arbitrary node N that is not a conditional
+ -- expression, one of whose dependent expressions is N, recursively.
+
+ function Unqualified_Unconditional_Parent (N : Node_Id) return Node_Id;
+ -- Return the first parent of arbitrary node N that is not a conditional
-- expression, one of whose dependent expressions is N, and that is not
-- a qualified expression, whose expression is N, recursively.