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