sem_util.adb (Copy_Node_With_Replacement): use Set_Comes_From_Source instead of direc...
authorArnaud Charlet <charlet@adacore.com>
Tue, 19 Apr 2016 12:24:29 +0000 (12:24 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Tue, 19 Apr 2016 12:24:29 +0000 (14:24 +0200)
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

gcc/ada/ChangeLog
gcc/ada/sem_aux.adb
gcc/ada/sem_util.adb

index 02ab36906a4f76655040a31bd38631ac2ccb641a..a063ef4f68eeb0a56c539607e1a62123abb3bd5e 100644 (file)
@@ -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
index f704f93d5de8622c26e02e9b1234ab58d6a39b34..79a3b9996a0f94c158d1330c68e85d0f7b7d0636 100644 (file)
@@ -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.
 
index 393ff73914b7c01f3d1e011363ba6786ab9606bf..5aabd25c3fab7573a0254da09146bb3407e3a776 100644 (file)
@@ -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;
 
    ----------------