diff options
Diffstat (limited to 'gcc/ada/exp_ch6.adb')
-rw-r--r-- | gcc/ada/exp_ch6.adb | 58 |
1 files changed, 7 insertions, 51 deletions
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index cd83d45bddc..9288e847734 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -4036,45 +4036,6 @@ package body Exp_Ch6 is ------------------------------- procedure Expand_Ctrl_Function_Call (N : Node_Id) is - function Enclosing_Context return Node_Id; - -- Find the enclosing context where the function call appears - - ----------------------- - -- Enclosing_Context -- - ----------------------- - - function Enclosing_Context return Node_Id is - Context : Node_Id; - - begin - Context := Parent (N); - while Present (Context) loop - - -- The following could use a comment (and why is N_Case_Expression - -- not treated in a similar manner ??? - - if Nkind (Context) = N_If_Expression then - exit; - - -- Stop the search when reaching any statement because we have - -- gone too far up the tree. - - elsif Nkind (Context) = N_Procedure_Call_Statement - or else Nkind (Context) in N_Statement_Other_Than_Procedure_Call - then - exit; - end if; - - Context := Parent (Context); - end loop; - - return Context; - end Enclosing_Context; - - -- Local variables - - Context : constant Node_Id := Enclosing_Context; - begin -- Optimization, if the returned value (which is on the sec-stack) is -- returned again, no need to copy/readjust/finalize, we can just pass @@ -4096,15 +4057,12 @@ package body Exp_Ch6 is Remove_Side_Effects (N); - -- The function call is part of an if expression dependent expression. - -- The temporary result must live as long as the if expression itself, - -- otherwise it will be finalized too early. Mark the transient as - -- processed to avoid untimely finalization. + -- When the temporary function result appears inside a case or an if + -- expression, its lifetime must be extended to match that of the + -- context. If not, the function result would be finalized prematurely + -- and the evaluation of the expression could yield the wrong result. - -- Why no special handling for case expressions here ??? - - if Present (Context) - and then Nkind (Context) = N_If_Expression + if Within_Case_Or_If_Expression (N) and then Nkind (N) = N_Explicit_Dereference then Set_Is_Processed_Transient (Entity (Prefix (N))); @@ -4223,9 +4181,7 @@ package body Exp_Ch6 is if Is_Entity_Name (N) and then Present (Entity (N)) then E := Entity (N); - if Is_Formal (E) - and then Scope (E) = Subp - then + if Is_Formal (E) and then Scope (E) = Subp then A := Renamed_Object (E); -- Rewrite the occurrence of the formal into an occurrence of |