Commit c12beea0 by Robert Dewar Committed by Arnaud Charlet

exp_ch6.adb, [...]: Use Make_Temporary

2010-06-17  Robert Dewar  <dewar@adacore.com>

	* exp_ch6.adb, exp_ch7.adb, exp_ch5.adb: Use Make_Temporary
	* tbuild.ads (Make_Temporary): More comment updates
	* tbuild.adb: Minor reformatting

From-SVN: r160894
parent 191fcb3a
2010-06-17 Robert Dewar <dewar@adacore.com> 2010-06-17 Robert Dewar <dewar@adacore.com>
* exp_ch6.adb, exp_ch7.adb, exp_ch5.adb: Use Make_Temporary
* tbuild.ads (Make_Temporary): More comment updates
* tbuild.adb: Minor reformatting
2010-06-17 Robert Dewar <dewar@adacore.com>
* checks.adb, exp_aggr.adb, exp_atag.adb, exp_attr.adb, exp_ch11.adb, * checks.adb, exp_aggr.adb, exp_atag.adb, exp_attr.adb, exp_ch11.adb,
exp_ch3.adb, exp_ch4.adb: Minor code reorganization. exp_ch3.adb, exp_ch4.adb: Minor code reorganization.
Use Make_Temporary. Use Make_Temporary.
......
...@@ -808,9 +808,7 @@ package body Exp_Ch6 is ...@@ -808,9 +808,7 @@ package body Exp_Ch6 is
Elm := First_Elmt (Var_List); Elm := First_Elmt (Var_List);
while Present (Elm) loop while Present (Elm) loop
Var := Node (Elm); Var := Node (Elm);
Ent := Ent := Make_Temporary (Loc, 'S');
Make_Defining_Identifier (Loc,
Chars => New_Internal_Name ('S'));
Append_Elmt (Ent, Shad_List); Append_Elmt (Ent, Shad_List);
-- Insert a declaration for this temporary at the start of the -- Insert a declaration for this temporary at the start of the
...@@ -966,9 +964,7 @@ package body Exp_Ch6 is ...@@ -966,9 +964,7 @@ package body Exp_Ch6 is
return; return;
end if; end if;
Temp := Temp := Make_Temporary (Loc, 'T');
Make_Defining_Identifier (Loc,
Chars => New_Internal_Name ('T'));
-- Use formal type for temp, unless formal type is an unconstrained -- Use formal type for temp, unless formal type is an unconstrained
-- array, in which case we don't have to worry about bounds checks, -- array, in which case we don't have to worry about bounds checks,
...@@ -1220,9 +1216,7 @@ package body Exp_Ch6 is ...@@ -1220,9 +1216,7 @@ package body Exp_Ch6 is
Reset_Packed_Prefix; Reset_Packed_Prefix;
Temp := Temp := Make_Temporary (Loc, 'T');
Make_Defining_Identifier (Loc,
Chars => New_Internal_Name ('T'));
Incod := Relocate_Node (Actual); Incod := Relocate_Node (Actual);
Outcod := New_Copy_Tree (Incod); Outcod := New_Copy_Tree (Incod);
...@@ -1387,9 +1381,7 @@ package body Exp_Ch6 is ...@@ -1387,9 +1381,7 @@ package body Exp_Ch6 is
return Entity (Actual); return Entity (Actual);
else else
Var := Var := Make_Temporary (Loc, 'T');
Make_Defining_Identifier (Loc,
Chars => New_Internal_Name ('T'));
N_Node := N_Node :=
Make_Object_Renaming_Declaration (Loc, Make_Object_Renaming_Declaration (Loc,
...@@ -3312,8 +3304,8 @@ package body Exp_Ch6 is ...@@ -3312,8 +3304,8 @@ package body Exp_Ch6 is
procedure Make_Exit_Label; procedure Make_Exit_Label;
-- Build declaration for exit label to be used in Return statements, -- Build declaration for exit label to be used in Return statements,
-- sets Exit_Lab (the label node) and Lab_Decl (corresponding implcit -- sets Exit_Lab (the label node) and Lab_Decl (corresponding implicit
-- declaration). -- declaration). Does nothing if Exit_Lab already set.
function Process_Formals (N : Node_Id) return Traverse_Result; function Process_Formals (N : Node_Id) return Traverse_Result;
-- Replace occurrence of a formal with the corresponding actual, or the -- Replace occurrence of a formal with the corresponding actual, or the
...@@ -3343,20 +3335,15 @@ package body Exp_Ch6 is ...@@ -3343,20 +3335,15 @@ package body Exp_Ch6 is
--------------------- ---------------------
procedure Make_Exit_Label is procedure Make_Exit_Label is
Lab_Ent : Entity_Id;
begin begin
-- Create exit label for subprogram if one does not exist yet
if No (Exit_Lab) then if No (Exit_Lab) then
Lab_Id := Lab_Ent := Make_Temporary (Loc, 'L');
Make_Identifier (Loc, Lab_Id := New_Reference_To (Lab_Ent, Loc);
Chars => New_Internal_Name ('L'));
Set_Entity (Lab_Id,
Make_Defining_Identifier (Loc, Chars (Lab_Id)));
Exit_Lab := Make_Label (Loc, Lab_Id); Exit_Lab := Make_Label (Loc, Lab_Id);
Lab_Decl := Lab_Decl :=
Make_Implicit_Label_Declaration (Loc, Make_Implicit_Label_Declaration (Loc,
Defining_Identifier => Entity (Lab_Id), Defining_Identifier => Lab_Ent,
Label_Construct => Exit_Lab); Label_Construct => Exit_Lab);
end if; end if;
end Make_Exit_Label; end Make_Exit_Label;
...@@ -3793,9 +3780,7 @@ package body Exp_Ch6 is ...@@ -3793,9 +3780,7 @@ package body Exp_Ch6 is
end if; end if;
else else
Temp := Temp := Make_Temporary (Loc, 'C');
Make_Defining_Identifier (Loc,
Chars => New_Internal_Name ('C'));
-- If the actual for an in/in-out parameter is a view conversion, -- If the actual for an in/in-out parameter is a view conversion,
-- make it into an unchecked conversion, given that an untagged -- make it into an unchecked conversion, given that an untagged
...@@ -3883,8 +3868,7 @@ package body Exp_Ch6 is ...@@ -3883,8 +3868,7 @@ package body Exp_Ch6 is
else else
-- Replace call with temporary and create its declaration -- Replace call with temporary and create its declaration
Temp := Temp := Make_Temporary (Loc, 'C');
Make_Defining_Identifier (Loc, New_Internal_Name ('C'));
Set_Is_Internal (Temp); Set_Is_Internal (Temp);
-- For the unconstrained case, the generated temporary has the -- For the unconstrained case, the generated temporary has the
...@@ -4611,9 +4595,7 @@ package body Exp_Ch6 is ...@@ -4611,9 +4595,7 @@ package body Exp_Ch6 is
declare declare
Decls : List_Id; Decls : List_Id;
Obj_Ptr : constant Entity_Id := Make_Defining_Identifier (Loc, Obj_Ptr : constant Entity_Id := Make_Temporary (Loc, 'T');
Chars =>
New_Internal_Name ('T'));
begin begin
Decls := New_List ( Decls := New_List (
...@@ -5117,8 +5099,7 @@ package body Exp_Ch6 is ...@@ -5117,8 +5099,7 @@ package body Exp_Ch6 is
-- Create a new access object and initialize it to the result of the -- Create a new access object and initialize it to the result of the
-- new uninitialized allocator. -- new uninitialized allocator.
Return_Obj_Access := Return_Obj_Access := Make_Temporary (Loc, 'R', Allocator);
Make_Defining_Identifier (Loc, New_Internal_Name ('R'));
Set_Etype (Return_Obj_Access, Acc_Type); Set_Etype (Return_Obj_Access, Acc_Type);
Insert_Action (Allocator, Insert_Action (Allocator,
...@@ -5251,9 +5232,7 @@ package body Exp_Ch6 is ...@@ -5251,9 +5232,7 @@ package body Exp_Ch6 is
-- Create a temporary object to hold the function result -- Create a temporary object to hold the function result
Return_Obj_Id := Return_Obj_Id := Make_Temporary (Loc, 'R');
Make_Defining_Identifier (Loc,
Chars => New_Internal_Name ('R'));
Set_Etype (Return_Obj_Id, Result_Subt); Set_Etype (Return_Obj_Id, Result_Subt);
Return_Obj_Decl := Return_Obj_Decl :=
...@@ -5406,8 +5385,7 @@ package body Exp_Ch6 is ...@@ -5406,8 +5385,7 @@ package body Exp_Ch6 is
-- Create an access type designating the function's result subtype -- Create an access type designating the function's result subtype
Ptr_Typ := Ptr_Typ := Make_Temporary (Loc, 'A');
Make_Defining_Identifier (Loc, New_Internal_Name ('A'));
Ptr_Typ_Decl := Ptr_Typ_Decl :=
Make_Full_Type_Declaration (Loc, Make_Full_Type_Declaration (Loc,
...@@ -5422,7 +5400,7 @@ package body Exp_Ch6 is ...@@ -5422,7 +5400,7 @@ package body Exp_Ch6 is
-- Finally, create an access object initialized to a reference to the -- Finally, create an access object initialized to a reference to the
-- function call. -- function call.
Obj_Id := Make_Defining_Identifier (Loc, New_Internal_Name ('R')); Obj_Id := Make_Temporary (Loc, 'R');
Set_Etype (Obj_Id, Ptr_Typ); Set_Etype (Obj_Id, Ptr_Typ);
Obj_Decl := Obj_Decl :=
...@@ -5684,8 +5662,7 @@ package body Exp_Ch6 is ...@@ -5684,8 +5662,7 @@ package body Exp_Ch6 is
-- Create an access type designating the function's result subtype -- Create an access type designating the function's result subtype
Ref_Type := Ref_Type := Make_Temporary (Loc, 'A');
Make_Defining_Identifier (Loc, New_Internal_Name ('A'));
Ptr_Typ_Decl := Ptr_Typ_Decl :=
Make_Full_Type_Declaration (Loc, Make_Full_Type_Declaration (Loc,
...@@ -5712,15 +5689,13 @@ package body Exp_Ch6 is ...@@ -5712,15 +5689,13 @@ package body Exp_Ch6 is
-- Finally, create an access object initialized to a reference to the -- Finally, create an access object initialized to a reference to the
-- function call. -- function call.
Def_Id :=
Make_Defining_Identifier (Loc,
Chars => New_Internal_Name ('R'));
Set_Etype (Def_Id, Ref_Type);
New_Expr := New_Expr :=
Make_Reference (Loc, Make_Reference (Loc,
Prefix => Relocate_Node (Func_Call)); Prefix => Relocate_Node (Func_Call));
Def_Id := Make_Temporary (Loc, 'R', New_Expr);
Set_Etype (Def_Id, Ref_Type);
Insert_After_And_Analyze (Ptr_Typ_Decl, Insert_After_And_Analyze (Ptr_Typ_Decl,
Make_Object_Declaration (Loc, Make_Object_Declaration (Loc,
Defining_Identifier => Def_Id, Defining_Identifier => Def_Id,
...@@ -5744,8 +5719,7 @@ package body Exp_Ch6 is ...@@ -5744,8 +5719,7 @@ package body Exp_Ch6 is
Rewrite (Object_Decl, Rewrite (Object_Decl,
Make_Object_Renaming_Declaration (Loc, Make_Object_Renaming_Declaration (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Defining_Identifier => Make_Temporary (Loc, 'D'),
New_Internal_Name ('D')),
Access_Definition => Empty, Access_Definition => Empty,
Subtype_Mark => New_Occurrence_Of (Result_Subt, Loc), Subtype_Mark => New_Occurrence_Of (Result_Subt, Loc),
Name => Call_Deref)); Name => Call_Deref));
......
...@@ -586,9 +586,7 @@ package body Exp_Ch7 is ...@@ -586,9 +586,7 @@ package body Exp_Ch7 is
-- Here we generate the required loop -- Here we generate the required loop
else else
Index := Index := Make_Temporary (Loc, 'J');
Make_Defining_Identifier (Loc, New_Internal_Name ('J'));
Append (New_Reference_To (Index, Loc), Index_List); Append (New_Reference_To (Index, Loc), Index_List);
return New_List ( return New_List (
...@@ -1162,7 +1160,7 @@ package body Exp_Ch7 is ...@@ -1162,7 +1160,7 @@ package body Exp_Ch7 is
and then not Sec_Stack_Needed_For_Return (Current_Scope) and then not Sec_Stack_Needed_For_Return (Current_Scope)
and then VM_Target = No_VM and then VM_Target = No_VM
then then
Mark := Make_Defining_Identifier (Loc, New_Internal_Name ('M')); Mark := Make_Temporary (Loc, 'M');
Append_To (New_Decls, Append_To (New_Decls,
Make_Object_Declaration (Loc, Make_Object_Declaration (Loc,
Defining_Identifier => Mark, Defining_Identifier => Mark,
...@@ -1785,9 +1783,7 @@ package body Exp_Ch7 is ...@@ -1785,9 +1783,7 @@ package body Exp_Ch7 is
end if; end if;
end if; end if;
Id := Id := Make_Temporary (Flist_Loc, 'F');
Make_Defining_Identifier (Flist_Loc,
Chars => New_Internal_Name ('F'));
end; end;
Set_Finalization_Chain_Entity (S, Id); Set_Finalization_Chain_Entity (S, Id);
...@@ -3438,7 +3434,7 @@ package body Exp_Ch7 is ...@@ -3438,7 +3434,7 @@ package body Exp_Ch7 is
-- Fxxx : Finalizable_Ptr renames Lxxx.F; -- Fxxx : Finalizable_Ptr renames Lxxx.F;
if Present (Finalization_Chain_Entity (S)) then if Present (Finalization_Chain_Entity (S)) then
LC := Make_Defining_Identifier (Loc, New_Internal_Name ('L')); LC := Make_Temporary (Loc, 'L');
-- Use the Sloc of the first declaration of N's containing list, to -- Use the Sloc of the first declaration of N's containing list, to
-- maintain monotonicity of source-line stepping during debugging. -- maintain monotonicity of source-line stepping during debugging.
......
...@@ -686,7 +686,6 @@ package body Tbuild is ...@@ -686,7 +686,6 @@ package body Tbuild is
Loc : Source_Ptr) return Node_Id Loc : Source_Ptr) return Node_Id
is is
Occurrence : Node_Id; Occurrence : Node_Id;
begin begin
Occurrence := New_Node (N_Identifier, Loc); Occurrence := New_Node (N_Identifier, Loc);
Set_Chars (Occurrence, Chars (Def_Id)); Set_Chars (Occurrence, Chars (Def_Id));
......
...@@ -180,15 +180,19 @@ package Tbuild is ...@@ -180,15 +180,19 @@ package Tbuild is
(Loc : Source_Ptr; (Loc : Source_Ptr;
Id : Character; Id : Character;
Related_Node : Node_Id := Empty) return Entity_Id; Related_Node : Node_Id := Empty) return Entity_Id;
-- This function should be used for all cases where a temporary is -- This function should be used for all cases where a defining identifier
-- built with a name to be obtained by New_Internal_Name (here Id is -- is to be built with a name to be obtained by New_Internal_Name (here Id
-- the character passed as the argument to New_Internal_Name). Loc -- is the character passed as the argument to New_Internal_Name). Loc is
-- is the location for the Sloc value of the resulting Entity. -- the location for the Sloc value of the resulting Entity. Note that this
-- can be used for all kinds of temporary defining identifiers used in
-- expansion (objects, subtypes, functions etc).
-- --
-- Related_Node is used when the identifier is capturing the value of -- Related_Node is used when the defining identifier is for an object that
-- an expression (e.g. an aggregate). It should be set whenever possible -- captures the value of an expression (e.g. an aggregate). It should be
-- to point to the expression that is being captured. This is provided -- set whenever possible to point to the expression that is being captured.
-- to get better error messages, especially from CodePeer reports. -- This is provided to get better error messages, e.g. from CodePeer.
--
-- Make_Temp_Id would probably be a better name for this function???
function Make_Unsuppress_Block function Make_Unsuppress_Block
(Loc : Source_Ptr; (Loc : Source_Ptr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment