From 738a0e8dd447409a960c84cf14d05e5bdc985ea6 Mon Sep 17 00:00:00 2001 From: Bob Duff Date: Mon, 17 May 2021 12:42:20 -0400 Subject: [Ada] Transient scope cleanup gcc/ada/ * checks.adb, exp_attr.adb, exp_ch4.adb, exp_ch6.adb, exp_ch9.adb, exp_disp.adb, exp_util.adb, inline.adb, sem_res.adb: Change all calls to Make_Unchecked_Type_Conversion to call Unchecked_Convert_To instead. This involves removing New_Occurrence_Of on the first parameter, because Unchecked_Convert_To expects a type entity, rather than the name of one. Also, removed calls to Relocate_Node, because Unchecked_Convert_To takes care of that. * sinfo.ads: Change comment to be worded more firmly. --- gcc/ada/exp_ch6.adb | 63 +++++++++++++++++------------------------------------ 1 file changed, 20 insertions(+), 43 deletions(-) (limited to 'gcc/ada/exp_ch6.adb') diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 80ed21b..c1409bf 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -5852,11 +5852,9 @@ package body Exp_Ch6 is Name => New_Occurrence_Of (Alloc_Obj_Id, Loc), Expression => - Make_Unchecked_Type_Conversion (Loc, - Subtype_Mark => - New_Occurrence_Of (Ref_Type, Loc), - Expression => - New_Occurrence_Of (Obj_Acc_Formal, Loc)))), + Unchecked_Convert_To + (Ref_Type, + New_Occurrence_Of (Obj_Acc_Formal, Loc)))), Elsif_Parts => New_List ( Make_Elsif_Part (Loc, @@ -5997,11 +5995,9 @@ package body Exp_Ch6 is Object_Definition => New_Occurrence_Of (Ref_Type, Loc), Expression => - Make_Unchecked_Type_Conversion (Loc, - Subtype_Mark => - New_Occurrence_Of (Ref_Type, Loc), - Expression => - New_Occurrence_Of (Obj_Acc_Formal, Loc))); + Unchecked_Convert_To + (Ref_Type, + New_Occurrence_Of (Obj_Acc_Formal, Loc))); Insert_Before (Ret_Obj_Decl, Alloc_Obj_Decl); @@ -8514,12 +8510,10 @@ package body Exp_Ch6 is Alloc_Form := Caller_Allocation; Pool := Make_Null (No_Location); - Return_Obj_Actual := - Make_Unchecked_Type_Conversion (Loc, - Subtype_Mark => New_Occurrence_Of (Result_Subt, Loc), - Expression => - Make_Explicit_Dereference (Loc, - Prefix => New_Occurrence_Of (Return_Obj_Access, Loc))); + Return_Obj_Actual := Unchecked_Convert_To + (Result_Subt, + Make_Explicit_Dereference (Loc, + Prefix => New_Occurrence_Of (Return_Obj_Access, Loc))); -- When the result subtype is unconstrained, the function itself must -- perform the allocation of the return object, so we pass parameters @@ -8833,11 +8827,7 @@ package body Exp_Ch6 is -- the caller's return object. Add_Access_Actual_To_Build_In_Place_Call - (Func_Call, - Func_Id, - Make_Unchecked_Type_Conversion (Loc, - Subtype_Mark => New_Occurrence_Of (Result_Subt, Loc), - Expression => Relocate_Node (Lhs))); + (Func_Call, Func_Id, Unchecked_Convert_To (Result_Subt, Lhs)); -- Create an access type designating the function's result subtype @@ -8861,11 +8851,7 @@ package body Exp_Ch6 is -- Add a conversion if it's the wrong type - if Etype (New_Expr) /= Ptr_Typ then - New_Expr := - Make_Unchecked_Type_Conversion (Loc, - New_Occurrence_Of (Ptr_Typ, Loc), New_Expr); - end if; + New_Expr := Unchecked_Convert_To (Ptr_Typ, New_Expr); Obj_Id := Make_Temporary (Loc, 'R', New_Expr); Set_Etype (Obj_Id, Ptr_Typ); @@ -9124,16 +9110,10 @@ package body Exp_Ch6 is -- it to the access type of the callee's BIP_Object_Access formal. Caller_Object := - Make_Unchecked_Type_Conversion (Loc, - Subtype_Mark => - New_Occurrence_Of - (Etype (Build_In_Place_Formal - (Function_Id, BIP_Object_Access)), - Loc), - Expression => - New_Occurrence_Of - (Build_In_Place_Formal (Encl_Func, BIP_Object_Access), - Loc)); + Unchecked_Convert_To + (Etype (Build_In_Place_Formal (Function_Id, BIP_Object_Access)), + New_Occurrence_Of + (Build_In_Place_Formal (Encl_Func, BIP_Object_Access), Loc)); -- In the definite case, add an implicit actual to the function call -- that provides access to the declared object. An unchecked conversion @@ -9141,10 +9121,8 @@ package body Exp_Ch6 is -- the case where the object is declared with a class-wide type. elsif Definite then - Caller_Object := - Make_Unchecked_Type_Conversion (Loc, - Subtype_Mark => New_Occurrence_Of (Result_Subt, Loc), - Expression => New_Occurrence_Of (Obj_Def_Id, Loc)); + Caller_Object := Unchecked_Convert_To + (Result_Subt, New_Occurrence_Of (Obj_Def_Id, Loc)); -- When the function has a controlling result, an allocation-form -- parameter must be passed indicating that the caller is allocating @@ -9252,9 +9230,8 @@ package body Exp_Ch6 is Constant_Present => True, Object_Definition => New_Occurrence_Of (Ptr_Typ, Loc), Expression => - Make_Unchecked_Type_Conversion (Loc, - New_Occurrence_Of (Ptr_Typ, Loc), - Make_Reference (Loc, Relocate_Node (Func_Call)))); + Unchecked_Convert_To + (Ptr_Typ, Make_Reference (Loc, Relocate_Node (Func_Call)))); else Res_Decl := Make_Object_Declaration (Loc, -- cgit v1.1