* [Ada] Transient scope cleanup
@ 2021-07-08 13:50 Pierre-Marie de Rodat
0 siblings, 0 replies; 2+ messages in thread
From: Pierre-Marie de Rodat @ 2021-07-08 13:50 UTC (permalink / raw)
To: gcc-patches; +Cc: Bob Duff
[-- Attachment #1: Type: text/plain, Size: 530 bytes --]
Misc cleanups found while working on transient scopes.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* comperr.adb (Compiler_Abort): Call Sinput.Unlock, because if
this is called late, then Source_Dump would crash otherwise.
* debug.adb: Correct documentation of the -gnatd.9 switch.
* exp_ch4.adb (Expand_Allocator_Expression): Add a comment.
* exp_ch6.adb: Minor comment fixes. Add assertion.
* exp_ch6.ads (Is_Build_In_Place_Result_Type): Correct comment.
* exp_ch7.adb, checks.ads: Minor comment fixes.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 6887 bytes --]
diff --git a/gcc/ada/checks.ads b/gcc/ada/checks.ads
--- a/gcc/ada/checks.ads
+++ b/gcc/ada/checks.ads
@@ -851,7 +851,7 @@ package Checks is
-- are not following the flow graph (more properly the flow of actual
-- processing only corresponds to the flow graph for local assignments).
-- For non-local variables, we preserve the current setting, i.e. a
- -- validity check is performed when assigning to a knonwn valid global.
+ -- validity check is performed when assigning to a known valid global.
-- Note: no validity checking is required if range checks are suppressed
-- regardless of the setting of the validity checking mode.
diff --git a/gcc/ada/comperr.adb b/gcc/ada/comperr.adb
--- a/gcc/ada/comperr.adb
+++ b/gcc/ada/comperr.adb
@@ -404,6 +404,7 @@ package body Comperr is
Set_Standard_Output;
Tree_Dump;
+ Sinput.Unlock; -- so Source_Dump can modify it
Source_Dump;
raise Unrecoverable_Error;
end if;
diff --git a/gcc/ada/debug.adb b/gcc/ada/debug.adb
--- a/gcc/ada/debug.adb
+++ b/gcc/ada/debug.adb
@@ -1101,7 +1101,7 @@ package body Debug is
-- issues (e.g., assuming that a low bound of an array parameter
-- of an unconstrained subtype belongs to the index subtype).
- -- d.9 Enable build-in-place for function calls returning some nonlimited
+ -- d.9 Disable build-in-place for function calls returning nonlimited
-- types.
------------------------------------------
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -1166,6 +1166,9 @@ package body Exp_Ch4 is
-- secondary stack). In that case, the object will be moved, so we do
-- want to Adjust. However, if it's a nonlimited build-in-place
-- function call, Adjust is not wanted.
+ --
+ -- Needs_Finalization (DesigT) can differ from Needs_Finalization (T)
+ -- if one of the two types is class-wide, and the other is not.
if Needs_Finalization (DesigT)
and then Needs_Finalization (T)
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
--- a/gcc/ada/exp_ch6.adb
+++ b/gcc/ada/exp_ch6.adb
@@ -4913,7 +4913,7 @@ package body Exp_Ch6 is
-- Optimization, if the returned value (which is on the sec-stack) is
-- returned again, no need to copy/readjust/finalize, we can just pass
-- the value thru (see Expand_N_Simple_Return_Statement), and thus no
- -- attachment is needed
+ -- attachment is needed.
if Nkind (Parent (N)) = N_Simple_Return_Statement then
return;
@@ -7310,15 +7310,16 @@ package body Exp_Ch6 is
Set_Enclosing_Sec_Stack_Return (N);
- -- Optimize the case where the result is a function call. In this
- -- case the result is already on the secondary stack and no further
- -- processing is required except to set the By_Ref flag to ensure
- -- that gigi does not attempt an extra unnecessary copy. (Actually
- -- not just unnecessary but wrong in the case of a controlled type,
- -- where gigi does not know how to do a copy.)
+ -- Optimize the case where the result is a function call that also
+ -- returns on the secondary stack. In this case the result is already
+ -- on the secondary stack and no further processing is required
+ -- except to set the By_Ref flag to ensure that gigi does not attempt
+ -- an extra unnecessary copy. (Actually not just unnecessary but
+ -- wrong in the case of a controlled type, where gigi does not know
+ -- how to do a copy.)
- if Requires_Transient_Scope (Exp_Typ)
- and then Exp_Is_Function_Call
+ pragma Assert (Requires_Transient_Scope (R_Type));
+ if Exp_Is_Function_Call and then Requires_Transient_Scope (Exp_Typ)
then
Set_By_Ref (N);
@@ -7849,7 +7850,7 @@ package body Exp_Ch6 is
Compute_Returns_By_Ref (Subp);
- -- Wnen freezing a null procedure, analyze its delayed aspects now
+ -- When freezing a null procedure, analyze its delayed aspects now
-- because we may not have reached the end of the declarative list when
-- delayed aspects are normally analyzed. This ensures that dispatching
-- calls are properly rewritten when the generated _Postcondition
@@ -8219,10 +8220,6 @@ package body Exp_Ch6 is
return False;
end if;
- -- For now we test whether E denotes a function or access-to-function
- -- type whose result subtype is inherently limited. Later this test
- -- may be revised to allow composite nonlimited types.
-
if Ekind (E) in E_Function | E_Generic_Function
or else (Ekind (E) = E_Subprogram_Type
and then Etype (E) /= Standard_Void_Type)
diff --git a/gcc/ada/exp_ch6.ads b/gcc/ada/exp_ch6.ads
--- a/gcc/ada/exp_ch6.ads
+++ b/gcc/ada/exp_ch6.ads
@@ -134,8 +134,11 @@ package Exp_Ch6 is
--
-- For inherently limited types in Ada 2005, True means that calls will
-- actually be build-in-place in all cases. For other types, build-in-place
- -- will be used when possible, but we need to make a copy at the call site
- -- in some cases, notably assignment statements.
+ -- will be used when possible, but we need to make a copy in some
+ -- cases. For example, for "X := F(...);" if F can see X, or if F can
+ -- propagate exceptions, we need to store its result in a temp in general,
+ -- and copy the temp into X. Also, for "return Global_Var;" Global_Var
+ -- needs to be copied into the function result object.
function Is_Build_In_Place_Function (E : Entity_Id) return Boolean;
-- Ada 2005 (AI-318-02): Returns True if E denotes a function, generic
diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb
--- a/gcc/ada/exp_ch7.adb
+++ b/gcc/ada/exp_ch7.adb
@@ -480,7 +480,7 @@ package body Exp_Ch7 is
Skip_Self : Boolean := False) return Node_Id;
-- Subsidiary to Make_Adjust_Call and Make_Final_Call. Given the entity of
-- routine [Deep_]Adjust or [Deep_]Finalize and an object parameter, create
- -- an adjust or finalization call. Wnen flag Skip_Self is set, the related
+ -- an adjust or finalization call. When flag Skip_Self is set, the related
-- action has an effect on the components only (if any).
function Make_Deep_Proc
@@ -8126,7 +8126,7 @@ package body Exp_Ch7 is
-- end if;
-- ...
- -- When Deep_Adjust is invokes for field _parent, a value of False is
+ -- When Deep_Adjust is invoked for field _parent, a value of False is
-- provided for the flag:
-- Deep_Adjust (Obj._parent, False);
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Ada] Transient scope cleanup
@ 2021-07-07 16:24 Pierre-Marie de Rodat
0 siblings, 0 replies; 2+ messages in thread
From: Pierre-Marie de Rodat @ 2021-07-07 16:24 UTC (permalink / raw)
To: gcc-patches; +Cc: Bob Duff
[-- Attachment #1: Type: text/plain, Size: 892 bytes --]
Use Tbuild.Unchecked_Convert_To instead of
Nmake.Make_Unchecked_Type_Conversion. This leads to more readable source
code in the compiler, and also more readable .dg code, because it
removes redundant unchecked conversions.
There is only one remaining call to Make_Unchecked_Type_Conversion,
which is in Unchecked_Convert_To.
Tested on x86_64-pc-linux-gnu, committed on trunk
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.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 25366 bytes --]
diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb
--- a/gcc/ada/checks.adb
+++ b/gcc/ada/checks.adb
@@ -7831,10 +7831,8 @@ package body Checks is
New_Occurrence_Of (Target_Base_Type, Loc),
Constant_Present => True,
Expression =>
- Make_Unchecked_Type_Conversion (Loc,
- Subtype_Mark =>
- New_Occurrence_Of (Target_Base_Type, Loc),
- Expression => Duplicate_Subexpr (N))),
+ Unchecked_Convert_To
+ (Target_Base_Type, Duplicate_Subexpr (N))),
Make_Raise_Constraint_Error (Loc,
Condition =>
diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb
--- a/gcc/ada/exp_attr.adb
+++ b/gcc/ada/exp_attr.adb
@@ -2799,10 +2799,9 @@ package body Exp_Attr is
Name =>
New_Occurrence_Of (RTE (RE_Callable), Loc),
Parameter_Associations => New_List (
- Make_Unchecked_Type_Conversion (Loc,
- Subtype_Mark =>
- New_Occurrence_Of (RTE (RO_ST_Task_Id), Loc),
- Expression => Build_Disp_Get_Task_Id_Call (Pref)))));
+ Unchecked_Convert_To
+ (RTE (RO_ST_Task_Id),
+ Build_Disp_Get_Task_Id_Call (Pref)))));
else
Rewrite (N, Build_Call_With_Task (Pref, RTE (RE_Callable)));
@@ -6746,10 +6745,9 @@ package body Exp_Attr is
Name =>
New_Occurrence_Of (RTE (RE_Terminated), Loc),
Parameter_Associations => New_List (
- Make_Unchecked_Type_Conversion (Loc,
- Subtype_Mark =>
- New_Occurrence_Of (RTE (RO_ST_Task_Id), Loc),
- Expression => Build_Disp_Get_Task_Id_Call (Pref)))));
+ Unchecked_Convert_To
+ (RTE (RO_ST_Task_Id),
+ Build_Disp_Get_Task_Id_Call (Pref)))));
elsif Restricted_Profile then
Rewrite (N,
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -11992,9 +11992,8 @@ package body Exp_Ch4 is
-- unchecked conversion to the target fixed-point type.
Conv :=
- Make_Unchecked_Type_Conversion (Loc,
- Subtype_Mark => New_Occurrence_Of (Target_Type, Loc),
- Expression => New_Occurrence_Of (Expr_Id, Loc));
+ Unchecked_Convert_To
+ (Target_Type, New_Occurrence_Of (Expr_Id, Loc));
end;
-- All other conversions
@@ -12515,10 +12514,7 @@ package body Exp_Ch4 is
Conv : Node_Id;
begin
Make_Tag_Check (Class_Wide_Type (Actual_Targ_Typ));
- Conv :=
- Make_Unchecked_Type_Conversion (Loc,
- Subtype_Mark => New_Occurrence_Of (Target_Type, Loc),
- Expression => Relocate_Node (Expression (N)));
+ Conv := Unchecked_Convert_To (Target_Type, Expression (N));
Rewrite (N, Conv);
Analyze_And_Resolve (N, Target_Type);
end;
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
--- 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,
diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb
--- a/gcc/ada/exp_ch9.adb
+++ b/gcc/ada/exp_ch9.adb
@@ -6510,14 +6510,12 @@ package body Exp_Ch9 is
-- Task_Id (Tasknm._disp_get_task_id)
- Make_Unchecked_Type_Conversion (Loc,
- Subtype_Mark =>
- New_Occurrence_Of (RTE (RO_ST_Task_Id), Loc),
- Expression =>
- Make_Selected_Component (Loc,
- Prefix => New_Copy_Tree (Tasknm),
- Selector_Name =>
- Make_Identifier (Loc, Name_uDisp_Get_Task_Id)))));
+ Unchecked_Convert_To
+ (RTE (RO_ST_Task_Id),
+ Make_Selected_Component (Loc,
+ Prefix => New_Copy_Tree (Tasknm),
+ Selector_Name =>
+ Make_Identifier (Loc, Name_uDisp_Get_Task_Id)))));
else
Append_To (Component_Associations (Aggr),
@@ -7242,10 +7240,9 @@ package body Exp_Ch9 is
Make_Assignment_Statement (Loc,
Name => New_Occurrence_Of (Bnn, Loc),
Expression =>
- Make_Unchecked_Type_Conversion (Loc,
- Subtype_Mark =>
- New_Occurrence_Of (RTE (RE_Communication_Block), Loc),
- Expression => Make_Identifier (Loc, Name_uD))));
+ Unchecked_Convert_To
+ (RTE (RE_Communication_Block),
+ Make_Identifier (Loc, Name_uD))));
-- Generate:
-- _Disp_Asynchronous_Select (<object>, S, P'Address, D, B);
@@ -7361,10 +7358,9 @@ package body Exp_Ch9 is
Name =>
New_Occurrence_Of (Bnn, Loc),
Expression =>
- Make_Unchecked_Type_Conversion (Loc,
- Subtype_Mark =>
- New_Occurrence_Of (RTE (RE_Communication_Block), Loc),
- Expression => Make_Identifier (Loc, Name_uD))));
+ Unchecked_Convert_To
+ (RTE (RE_Communication_Block),
+ Make_Identifier (Loc, Name_uD))));
-- Generate:
-- _Disp_Asynchronous_Select (<object>, S, P'Address, D, B);
diff --git a/gcc/ada/exp_disp.adb b/gcc/ada/exp_disp.adb
--- a/gcc/ada/exp_disp.adb
+++ b/gcc/ada/exp_disp.adb
@@ -2575,11 +2575,9 @@ package body Exp_Disp is
New_List (
Obj_Ref,
- Make_Unchecked_Type_Conversion (Loc, -- entry index
- Subtype_Mark =>
- New_Occurrence_Of
- (RTE (RE_Protected_Entry_Index), Loc),
- Expression => Make_Identifier (Loc, Name_uI)),
+ Unchecked_Convert_To ( -- entry index
+ RTE (RE_Protected_Entry_Index),
+ Make_Identifier (Loc, Name_uI)),
Make_Identifier (Loc, Name_uP), -- parameter block
New_Occurrence_Of -- Asynchronous_Call
@@ -2598,11 +2596,9 @@ package body Exp_Disp is
Make_Assignment_Statement (Loc,
Name => Make_Identifier (Loc, Name_uB),
Expression =>
- Make_Unchecked_Type_Conversion (Loc,
- Subtype_Mark =>
- New_Occurrence_Of
- (RTE (RE_Dummy_Communication_Block), Loc),
- Expression => New_Occurrence_Of (Com_Block, Loc))));
+ Unchecked_Convert_To
+ (RTE (RE_Dummy_Communication_Block),
+ New_Occurrence_Of (Com_Block, Loc))));
-- Generate:
-- F := False;
@@ -2636,10 +2632,9 @@ package body Exp_Disp is
Prefix => Make_Identifier (Loc, Name_uT),
Selector_Name => Make_Identifier (Loc, Name_uTask_Id)),
- Make_Unchecked_Type_Conversion (Loc, -- entry index
- Subtype_Mark =>
- New_Occurrence_Of (RTE (RE_Task_Entry_Index), Loc),
- Expression => Make_Identifier (Loc, Name_uI)),
+ Unchecked_Convert_To ( -- entry index
+ RTE (RE_Task_Entry_Index),
+ Make_Identifier (Loc, Name_uI)),
Make_Identifier (Loc, Name_uP), -- parameter block
New_Occurrence_Of -- Asynchronous_Call
@@ -2929,11 +2924,9 @@ package body Exp_Disp is
Parameter_Associations => New_List (
Obj_Ref,
- Make_Unchecked_Type_Conversion (Loc, -- entry index
- Subtype_Mark =>
- New_Occurrence_Of
- (RTE (RE_Protected_Entry_Index), Loc),
- Expression => Make_Identifier (Loc, Name_uI)),
+ Unchecked_Convert_To ( -- entry index
+ RTE (RE_Protected_Entry_Index),
+ Make_Identifier (Loc, Name_uI)),
Make_Identifier (Loc, Name_uP), -- parameter block
@@ -3006,10 +2999,9 @@ package body Exp_Disp is
Prefix => Make_Identifier (Loc, Name_uT),
Selector_Name => Make_Identifier (Loc, Name_uTask_Id)),
- Make_Unchecked_Type_Conversion (Loc, -- entry index
- Subtype_Mark =>
- New_Occurrence_Of (RTE (RE_Task_Entry_Index), Loc),
- Expression => Make_Identifier (Loc, Name_uI)),
+ Unchecked_Convert_To ( -- entry index
+ RTE (RE_Task_Entry_Index),
+ Make_Identifier (Loc, Name_uI)),
Make_Identifier (Loc, Name_uP), -- parameter block
New_Occurrence_Of -- Conditional_Call
@@ -3219,12 +3211,11 @@ package body Exp_Disp is
Ret :=
Make_Simple_Return_Statement (Loc,
Expression =>
- Make_Unchecked_Type_Conversion (Loc,
- Subtype_Mark => New_Occurrence_Of (RTE (RE_Address), Loc),
- Expression =>
- Make_Selected_Component (Loc,
- Prefix => Make_Identifier (Loc, Name_uT),
- Selector_Name => Make_Identifier (Loc, Name_uTask_Id))));
+ Unchecked_Convert_To
+ (RTE (RE_Address),
+ Make_Selected_Component (Loc,
+ Prefix => Make_Identifier (Loc, Name_uT),
+ Selector_Name => Make_Identifier (Loc, Name_uTask_Id))));
-- A null body is constructed for non-task types
@@ -3337,12 +3328,9 @@ package body Exp_Disp is
Parameter_Associations =>
New_List (
- Make_Unchecked_Type_Conversion (Loc, -- PEA (P)
- Subtype_Mark =>
- New_Occurrence_Of (
- RTE (RE_Protection_Entries_Access), Loc),
- Expression =>
- Make_Identifier (Loc, Name_uP)),
+ Unchecked_Convert_To ( -- PEA (P)
+ RTE (RE_Protection_Entries_Access),
+ Make_Identifier (Loc, Name_uP)),
Make_Attribute_Reference (Loc, -- O._object'Acc
Attribute_Name =>
@@ -3354,11 +3342,9 @@ package body Exp_Disp is
Selector_Name =>
Make_Identifier (Loc, Name_uObject))),
- Make_Unchecked_Type_Conversion (Loc, -- entry index
- Subtype_Mark =>
- New_Occurrence_Of
- (RTE (RE_Protected_Entry_Index), Loc),
- Expression => Make_Identifier (Loc, Name_uI)),
+ Unchecked_Convert_To ( -- entry index
+ RTE (RE_Protected_Entry_Index),
+ Make_Identifier (Loc, Name_uI)),
Make_Identifier (Loc, Name_uA)))), -- abort status
@@ -3383,11 +3369,9 @@ package body Exp_Disp is
Selector_Name =>
Make_Identifier (Loc, Name_uObject))),
- Make_Unchecked_Type_Conversion (Loc, -- entry index
- Subtype_Mark =>
- New_Occurrence_Of
- (RTE (RE_Protected_Entry_Index), Loc),
- Expression => Make_Identifier (Loc, Name_uI)),
+ Unchecked_Convert_To ( -- entry index
+ RTE (RE_Protected_Entry_Index),
+ Make_Identifier (Loc, Name_uI)),
Make_Identifier (Loc, Name_uA)))))); -- abort status
end if;
@@ -3424,20 +3408,17 @@ package body Exp_Disp is
Parameter_Associations => New_List (
- Make_Unchecked_Type_Conversion (Loc, -- PEA (P)
- Subtype_Mark =>
- New_Occurrence_Of
- (RTE (RE_Protection_Entries_Access), Loc),
- Expression => Make_Identifier (Loc, Name_uP)),
+ Unchecked_Convert_To ( -- PEA (P)
+ RTE (RE_Protection_Entries_Access),
+ Make_Identifier (Loc, Name_uP)),
Make_Selected_Component (Loc, -- O._task_id
Prefix => Make_Identifier (Loc, Name_uO),
Selector_Name => Make_Identifier (Loc, Name_uTask_Id)),
- Make_Unchecked_Type_Conversion (Loc, -- entry index
- Subtype_Mark =>
- New_Occurrence_Of (RTE (RE_Task_Entry_Index), Loc),
- Expression => Make_Identifier (Loc, Name_uI)),
+ Unchecked_Convert_To ( -- entry index
+ RTE (RE_Task_Entry_Index),
+ Make_Identifier (Loc, Name_uI)),
Make_Identifier (Loc, Name_uA)))), -- abort status
@@ -3455,10 +3436,9 @@ package body Exp_Disp is
Prefix => Make_Identifier (Loc, Name_uO),
Selector_Name => Make_Identifier (Loc, Name_uTask_Id)),
- Make_Unchecked_Type_Conversion (Loc, -- entry index
- Subtype_Mark =>
- New_Occurrence_Of (RTE (RE_Task_Entry_Index), Loc),
- Expression => Make_Identifier (Loc, Name_uI)),
+ Unchecked_Convert_To ( -- entry index
+ RTE (RE_Task_Entry_Index),
+ Make_Identifier (Loc, Name_uI)),
Make_Identifier (Loc, Name_uA)))))); -- abort status
end if;
@@ -3743,11 +3723,9 @@ package body Exp_Disp is
Parameter_Associations => New_List (
Obj_Ref,
- Make_Unchecked_Type_Conversion (Loc, -- entry index
- Subtype_Mark =>
- New_Occurrence_Of
- (RTE (RE_Protected_Entry_Index), Loc),
- Expression => Make_Identifier (Loc, Name_uI)),
+ Unchecked_Convert_To ( -- entry index
+ RTE (RE_Protected_Entry_Index),
+ Make_Identifier (Loc, Name_uI)),
Make_Identifier (Loc, Name_uP), -- parameter block
Make_Identifier (Loc, Name_uD), -- delay
@@ -3786,10 +3764,9 @@ package body Exp_Disp is
Prefix => Make_Identifier (Loc, Name_uT),
Selector_Name => Make_Identifier (Loc, Name_uTask_Id)),
- Make_Unchecked_Type_Conversion (Loc, -- entry index
- Subtype_Mark =>
- New_Occurrence_Of (RTE (RE_Task_Entry_Index), Loc),
- Expression => Make_Identifier (Loc, Name_uI)),
+ Unchecked_Convert_To ( -- entry index
+ RTE (RE_Task_Entry_Index),
+ Make_Identifier (Loc, Name_uI)),
Make_Identifier (Loc, Name_uP), -- parameter block
Make_Identifier (Loc, Name_uD), -- delay
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -1467,9 +1467,7 @@ package body Exp_Util is
Make_Procedure_Call_Statement (Loc,
Name => New_Occurrence_Of (Proc_Id, Loc),
Parameter_Associations => New_List (
- Make_Unchecked_Type_Conversion (Loc,
- Subtype_Mark => New_Occurrence_Of (Formal_Typ, Loc),
- Expression => Obj_Name)));
+ Unchecked_Convert_To (Formal_Typ, Obj_Name)));
end Build_DIC_Call;
------------------------------
diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb
--- a/gcc/ada/inline.adb
+++ b/gcc/ada/inline.adb
@@ -3008,10 +3008,7 @@ package body Inline is
if Nkind (A) = N_Type_Conversion
and then Ekind (F) /= E_In_Parameter
then
- New_A :=
- Make_Unchecked_Type_Conversion (Loc,
- Subtype_Mark => New_Occurrence_Of (Etype (F), Loc),
- Expression => Relocate_Node (Expression (A)));
+ New_A := Unchecked_Convert_To (Etype (F), Expression (A));
-- In GNATprove mode, keep the most precise type of the actual for
-- the temporary variable, when the formal type is unconstrained.
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -8825,18 +8825,12 @@ package body Sem_Res is
or else Is_Private_Type (T))
then
if Etype (L) /= T then
- Rewrite (L,
- Make_Unchecked_Type_Conversion (Sloc (L),
- Subtype_Mark => New_Occurrence_Of (T, Sloc (L)),
- Expression => Relocate_Node (L)));
+ Rewrite (L, Unchecked_Convert_To (T, L));
Analyze_And_Resolve (L, T);
end if;
if (Etype (R)) /= T then
- Rewrite (R,
- Make_Unchecked_Type_Conversion (Sloc (R),
- Subtype_Mark => New_Occurrence_Of (Etype (L), Sloc (R)),
- Expression => Relocate_Node (R)));
+ Rewrite (R, Unchecked_Convert_To (Etype (L), R));
Analyze_And_Resolve (R, T);
end if;
end if;
@@ -12740,10 +12734,7 @@ package body Sem_Res is
Set_Etype (Array_Subtype, Base_Type (Typ));
Set_Is_Constrained (Array_Subtype, True);
- Rewrite (N,
- Make_Unchecked_Type_Conversion (Loc,
- Subtype_Mark => New_Occurrence_Of (Array_Subtype, Loc),
- Expression => Relocate_Node (N)));
+ Rewrite (N, Unchecked_Convert_To (Array_Subtype, N));
Set_Etype (N, Array_Subtype);
end;
end if;
diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads
--- a/gcc/ada/sinfo.ads
+++ b/gcc/ada/sinfo.ads
@@ -8422,7 +8422,7 @@ package Sinfo is
-- It is generated as a result of actual use of Unchecked_Conversion
-- and also by the expander.
- -- Unchecked type conversion nodes should normally be created by calling
+ -- Unchecked type conversion nodes should be created by calling
-- Tbuild.Unchecked_Convert_To, rather than by directly calling
-- Nmake.Make_Unchecked_Type_Conversion.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-08 13:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-08 13:50 [Ada] Transient scope cleanup Pierre-Marie de Rodat
-- strict thread matches above, loose matches on Subject: below --
2021-07-07 16:24 Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).