aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/exp_ch6.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/exp_ch6.adb')
-rw-r--r--gcc/ada/exp_ch6.adb23
1 files changed, 14 insertions, 9 deletions
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
index 26302ba..c24c8c6 100644
--- a/gcc/ada/exp_ch6.adb
+++ b/gcc/ada/exp_ch6.adb
@@ -287,10 +287,11 @@ package body Exp_Ch6 is
-- This expansion is necessary in all the cases where the constant object
-- denoted by the call needs finalization in the current subprogram, which
- -- excludes return statements, and is not identified with another object
- -- that will be finalized, which excludes (statically) declared objects,
- -- dynamically allocated objects, components of aggregates, and targets of
- -- assignments that are done directly (without intermediate temporaries).
+ -- excludes simple return statements, and is not identified with another
+ -- object that will be finalized, which excludes (statically) declared
+ -- objects, dynamically allocated objects, components of aggregates, and
+ -- targets of assignments that are done directly (without intermediate
+ -- temporaries).
procedure Expand_Non_Function_Return (N : Node_Id);
-- Expand a simple return statement found in a procedure body, entry body,
@@ -5387,8 +5388,13 @@ package body Exp_Ch6 is
-- Note that object declarations are also distributed into conditional
-- expressions, but we may be invoked before this distribution is done.
+ -- However that's not the case for the declarations of return objects,
+ -- see the twin Is_Optimizable_Declaration predicates that are present
+ -- in Expand_N_Case_Expression and Expand_N_If_Expression of Exp_Ch4.
- elsif Nkind (Uncond_Par) = N_Object_Declaration then
+ elsif Nkind (Uncond_Par) = N_Object_Declaration
+ and then not Is_Return_Object (Defining_Identifier (Uncond_Par))
+ then
return;
end if;
@@ -5764,7 +5770,7 @@ package body Exp_Ch6 is
exception
when RE_Not_Available =>
- return;
+ null;
end Expand_N_Simple_Return_Statement;
------------------------------
@@ -9575,9 +9581,8 @@ package body Exp_Ch6 is
-- such build-in-place functions, primitive or not.
return not Restriction_Active (No_Finalization)
- and then ((Needs_Finalization (Typ)
- and then not Has_Relaxed_Finalization (Typ))
- or else Is_Tagged_Type (Typ))
+ and then (Needs_Finalization (Typ) or else Is_Tagged_Type (Typ))
+ and then not Has_Relaxed_Finalization (Typ)
and then not Has_Foreign_Convention (Typ);
end Needs_BIP_Collection;