diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2013-04-11 12:49:20 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2013-04-11 12:49:20 +0200 |
commit | 1486a00e3be13869fa6b38d75643df52499a535f (patch) | |
tree | 472187c53e844b31ee1d04946b7c4bea3475ae75 /gcc/ada/exp_ch4.adb | |
parent | fc142f6327838046dd9d363de53fad60771304e2 (diff) | |
download | gcc-1486a00e3be13869fa6b38d75643df52499a535f.zip gcc-1486a00e3be13869fa6b38d75643df52499a535f.tar.gz gcc-1486a00e3be13869fa6b38d75643df52499a535f.tar.bz2 |
[multiple changes]
2013-04-11 Hristian Kirtchev <kirtchev@adacore.com>
* exp_ch4.adb (Process_Transient_Object): Add new
local variable Fin_Call. Remove and explain ??? comment. Use the
Actions of logical operators "and then" and "or else" to insert
the generated finalization call.
2013-04-11 Eric Botcazou <ebotcazou@adacore.com>
* gnat_rm.texi: Fix typo.
2013-04-11 Ed Schonberg <schonberg@adacore.com>
* sem_res.adb: Minor reformatting.
From-SVN: r197767
Diffstat (limited to 'gcc/ada/exp_ch4.adb')
-rw-r--r-- | gcc/ada/exp_ch4.adb | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 779466a..be011f8 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -5166,8 +5166,8 @@ package body Exp_Ch4 is if Nkind_In (Par, N_Assignment_Statement, N_Object_Declaration, N_Pragma, - N_Simple_Return_Statement, - N_Procedure_Call_Statement) + N_Procedure_Call_Statement, + N_Simple_Return_Statement) then return Par; @@ -5192,6 +5192,7 @@ package body Exp_Ch4 is Obj_Typ : constant Node_Id := Etype (Obj_Id); Desig_Typ : Entity_Id; Expr : Node_Id; + Fin_Call : Node_Id; Ptr_Id : Entity_Id; Temp_Id : Entity_Id; @@ -5244,9 +5245,12 @@ package body Exp_Ch4 is -- Step 3: Hook the transient object to the temporary - if Is_Access_Type (Obj_Typ) then + -- The use of unchecked conversion / unrestricted access is needed + -- to avoid an accessibility violation. Note that the finalization + -- code is structured in such a way that the "hook" is processed + -- only when it points to an existing object. - -- Why is this an unchecked conversion ??? + if Is_Access_Type (Obj_Typ) then Expr := Unchecked_Convert_To (Ptr_Id, New_Reference_To (Obj_Id, Loc)); else @@ -5282,7 +5286,7 @@ package body Exp_Ch4 is -- the return statement as this would make it unreachable. if Nkind (Context) /= N_Simple_Return_Statement then - Insert_Action_After (Context, + Fin_Call := Make_Implicit_If_Statement (Obj_Decl, Condition => Make_Op_Ne (Loc, @@ -5298,7 +5302,17 @@ package body Exp_Ch4 is Make_Assignment_Statement (Loc, Name => New_Reference_To (Temp_Id, Loc), - Expression => Make_Null (Loc))))); + Expression => Make_Null (Loc)))); + + -- Use the Actions list of logical operators when inserting the + -- finalization call. This ensures that all transient objects + -- are finalized after the operators are evaluated. + + if Nkind_In (Context, N_And_Then, N_Or_Else) then + Insert_Action (Context, Fin_Call); + else + Insert_Action_After (Context, Fin_Call); + end if; end if; end Process_Transient_Object; |