aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ada/ChangeLog13
-rw-r--r--gcc/ada/sem_aux.adb28
-rw-r--r--gcc/ada/sem_util.adb17
3 files changed, 25 insertions, 33 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 02ab369..a063ef4 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,16 @@
+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>
* sem_res.adb (Resolve_Entry_Call): If the entry has
diff --git a/gcc/ada/sem_aux.adb b/gcc/ada/sem_aux.adb
index f704f93..79a3b99 100644
--- a/gcc/ada/sem_aux.adb
+++ b/gcc/ada/sem_aux.adb
@@ -611,11 +611,9 @@ package body Sem_Aux is
Nam : Name_Id;
Check_Parents : Boolean := True) return Node_Id
is
- N : Node_Id;
+ N : constant Node_Id := Get_Rep_Item (E, Nam, Check_Parents);
begin
- N := Get_Rep_Item (E, Nam, Check_Parents);
-
if Present (N) and then Nkind (N) = N_Pragma then
return N;
end if;
@@ -1381,12 +1379,10 @@ package body Sem_Aux is
-----------------------
function Number_Components (Typ : Entity_Id) return Nat is
- N : Int;
+ N : Nat := 0;
Comp : Entity_Id;
begin
- N := 0;
-
-- We do not call Einfo.First_Component_Or_Discriminant, as this
-- function does not skip completely hidden discriminants, which we
-- want to skip here.
@@ -1410,12 +1406,10 @@ package body Sem_Aux is
--------------------------
function Number_Discriminants (Typ : Entity_Id) return Pos is
- N : Int;
- Discr : Entity_Id;
+ N : Nat := 0;
+ Discr : Entity_Id := First_Discriminant (Typ);
begin
- N := 0;
- Discr := First_Discriminant (Typ);
while Present (Discr) loop
N := N + 1;
Discr := Next_Discriminant (Discr);
@@ -1521,13 +1515,10 @@ package body Sem_Aux 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
- -- Retrieve the declaration for E
-
- N := Parent (Subprogram_Specification (E));
-
-- If this declaration is not a subprogram body, then it must be a
-- subprogram declaration or body stub, from which we can retrieve the
-- entity for the corresponding subprogram body if any, or an abstract
@@ -1550,13 +1541,10 @@ package body Sem_Aux 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
- -- Retrieve the declaration for E
-
- N := Parent (Subprogram_Specification (E));
-
-- This declaration is either subprogram declaration or a subprogram
-- body, in which case return Empty.
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 393ff73..5aabd25 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -15735,8 +15735,9 @@ package body Sem_Util is
-- a completely new node, so the Comes_From_Source flag
-- should be reset to the proper default value.
- Nodes.Table (New_Node).Comes_From_Source :=
- Default_Node.Comes_From_Source;
+ Set_Comes_From_Source (New_Node,
+ Default_Node.Comes_From_Source);
+
end if;
-- If the node is call and has named associations,
@@ -20179,18 +20180,8 @@ package body Sem_Util is
------------------
function Within_Scope (E : Entity_Id; S : Entity_Id) return Boolean is
- SE : Entity_Id;
begin
- SE := Scope (E);
- loop
- if SE = S then
- return True;
- elsif SE = Standard_Standard then
- return False;
- else
- SE := Scope (SE);
- end if;
- end loop;
+ return Scope_Within_Or_Same (Scope (E), S);
end Within_Scope;
----------------