Commit 4754d4e8 by Arnaud Charlet Committed by Arnaud Charlet

sem_util.adb (Copy_Node_With_Replacement): use Set_Comes_From_Source instead of…

sem_util.adb (Copy_Node_With_Replacement): use Set_Comes_From_Source instead of directly manipulating internals of the...

2016-04-19  Arnaud Charlet  <charlet@adacore.com>

	* sem_util.adb (Copy_Node_With_Replacement):
	use Set_Comes_From_Source instead of directly manipulating
	internals of the node table.
	* sem_util.adb (Within_Scope): refactored to remove duplicated code.
	* sem_aux.adb (Get_Rep_Pragma,
	Subprogram_Body_Entity, Subprogram_Spec): declare variables that
	do not change as constants and initialize them in the declaration.
	(Get_Rep_Pragma, Subprogram_Body_Entity, Subprogram_Spec): declare
	variables that do not change as constants and initialize them
	in the declaration.

From-SVN: r235193
parent 87fd6836
2016-04-19 Arnaud Charlet <charlet@adacore.com>
* sem_util.adb (Copy_Node_With_Replacement):
use Set_Comes_From_Source instead of directly manipulating
internals of the node table.
* sem_util.adb (Within_Scope): refactored to remove duplicated code.
* sem_aux.adb (Get_Rep_Pragma,
Subprogram_Body_Entity, Subprogram_Spec): declare variables that
do not change as constants and initialize them in the declaration.
(Get_Rep_Pragma, Subprogram_Body_Entity, Subprogram_Spec): declare
variables that do not change as constants and initialize them
in the declaration.
2016-04-19 Ed Schonberg <schonberg@adacore.com> 2016-04-19 Ed Schonberg <schonberg@adacore.com>
* sem_res.adb (Resolve_Entry_Call): If the entry has * sem_res.adb (Resolve_Entry_Call): If the entry has
......
...@@ -611,11 +611,9 @@ package body Sem_Aux is ...@@ -611,11 +611,9 @@ package body Sem_Aux is
Nam : Name_Id; Nam : Name_Id;
Check_Parents : Boolean := True) return Node_Id Check_Parents : Boolean := True) return Node_Id
is is
N : Node_Id; N : constant Node_Id := Get_Rep_Item (E, Nam, Check_Parents);
begin begin
N := Get_Rep_Item (E, Nam, Check_Parents);
if Present (N) and then Nkind (N) = N_Pragma then if Present (N) and then Nkind (N) = N_Pragma then
return N; return N;
end if; end if;
...@@ -1381,12 +1379,10 @@ package body Sem_Aux is ...@@ -1381,12 +1379,10 @@ package body Sem_Aux is
----------------------- -----------------------
function Number_Components (Typ : Entity_Id) return Nat is function Number_Components (Typ : Entity_Id) return Nat is
N : Int; N : Nat := 0;
Comp : Entity_Id; Comp : Entity_Id;
begin begin
N := 0;
-- We do not call Einfo.First_Component_Or_Discriminant, as this -- We do not call Einfo.First_Component_Or_Discriminant, as this
-- function does not skip completely hidden discriminants, which we -- function does not skip completely hidden discriminants, which we
-- want to skip here. -- want to skip here.
...@@ -1410,12 +1406,10 @@ package body Sem_Aux is ...@@ -1410,12 +1406,10 @@ package body Sem_Aux is
-------------------------- --------------------------
function Number_Discriminants (Typ : Entity_Id) return Pos is function Number_Discriminants (Typ : Entity_Id) return Pos is
N : Int; N : Nat := 0;
Discr : Entity_Id; Discr : Entity_Id := First_Discriminant (Typ);
begin begin
N := 0;
Discr := First_Discriminant (Typ);
while Present (Discr) loop while Present (Discr) loop
N := N + 1; N := N + 1;
Discr := Next_Discriminant (Discr); Discr := Next_Discriminant (Discr);
...@@ -1521,13 +1515,10 @@ package body Sem_Aux is ...@@ -1521,13 +1515,10 @@ package body Sem_Aux is
---------------------------- ----------------------------
function Subprogram_Body_Entity (E : Entity_Id) return Entity_Id is function Subprogram_Body_Entity (E : Entity_Id) return Entity_Id is
N : Node_Id; N : constant Node_Id := Parent (Subprogram_Specification (E));
-- Declaration for E
begin begin
-- Retrieve the declaration for E
N := Parent (Subprogram_Specification (E));
-- If this declaration is not a subprogram body, then it must be a -- If this declaration is not a subprogram body, then it must be a
-- subprogram declaration or body stub, from which we can retrieve the -- subprogram declaration or body stub, from which we can retrieve the
-- entity for the corresponding subprogram body if any, or an abstract -- entity for the corresponding subprogram body if any, or an abstract
...@@ -1550,13 +1541,10 @@ package body Sem_Aux is ...@@ -1550,13 +1541,10 @@ package body Sem_Aux is
--------------------- ---------------------
function Subprogram_Spec (E : Entity_Id) return Node_Id is function Subprogram_Spec (E : Entity_Id) return Node_Id is
N : Node_Id; N : constant Node_Id := Parent (Subprogram_Specification (E));
-- Declaration for E
begin begin
-- Retrieve the declaration for E
N := Parent (Subprogram_Specification (E));
-- This declaration is either subprogram declaration or a subprogram -- This declaration is either subprogram declaration or a subprogram
-- body, in which case return Empty. -- body, in which case return Empty.
......
...@@ -15735,8 +15735,9 @@ package body Sem_Util is ...@@ -15735,8 +15735,9 @@ package body Sem_Util is
-- a completely new node, so the Comes_From_Source flag -- a completely new node, so the Comes_From_Source flag
-- should be reset to the proper default value. -- should be reset to the proper default value.
Nodes.Table (New_Node).Comes_From_Source := Set_Comes_From_Source (New_Node,
Default_Node.Comes_From_Source; Default_Node.Comes_From_Source);
end if; end if;
-- If the node is call and has named associations, -- If the node is call and has named associations,
...@@ -20179,18 +20180,8 @@ package body Sem_Util is ...@@ -20179,18 +20180,8 @@ package body Sem_Util is
------------------ ------------------
function Within_Scope (E : Entity_Id; S : Entity_Id) return Boolean is function Within_Scope (E : Entity_Id; S : Entity_Id) return Boolean is
SE : Entity_Id;
begin begin
SE := Scope (E); return Scope_Within_Or_Same (Scope (E), S);
loop
if SE = S then
return True;
elsif SE = Standard_Standard then
return False;
else
SE := Scope (SE);
end if;
end loop;
end Within_Scope; end Within_Scope;
---------------- ----------------
......
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