public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-2073] [Ada] Simplify unit loading with membership tests
@ 2021-07-06 14:49 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-07-06 14:49 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:ca290f108a62e041ea3ca7c981d8225f34cefdbd

commit r12-2073-gca290f108a62e041ea3ca7c981d8225f34cefdbd
Author: Piotr Trojanek <trojanek@adacore.com>
Date:   Mon May 10 18:00:46 2021 +0200

    [Ada] Simplify unit loading with membership tests
    
    gcc/ada/
    
            * lib-load.adb (Load_Unit): Remove excessive whitespace.
            * lib.adb (Is_Internal_Unit, Is_Predefined_Unit): Likewise.
            * par-ch10.adb (P_Compilation_Unit): Simplify with membership
            test.
            * par-load.adb (Load): Likewise.
            * uname.adb (Get_Unit_Name): Likewise.

Diff:
---
 gcc/ada/lib-load.adb | 16 ++++++++--------
 gcc/ada/lib.adb      | 14 ++++----------
 gcc/ada/par-ch10.adb |  2 +-
 gcc/ada/par-load.adb | 22 +++++++---------------
 gcc/ada/uname.adb    |  4 ++--
 5 files changed, 22 insertions(+), 36 deletions(-)

diff --git a/gcc/ada/lib-load.adb b/gcc/ada/lib-load.adb
index 330faa70f53..75b52e2240a 100644
--- a/gcc/ada/lib-load.adb
+++ b/gcc/ada/lib-load.adb
@@ -396,14 +396,14 @@ package body Lib.Load is
    ---------------
 
    function Load_Unit
-     (Load_Name         : Unit_Name_Type;
-      Required          : Boolean;
-      Error_Node        : Node_Id;
-      Subunit           : Boolean;
-      Corr_Body         : Unit_Number_Type := No_Unit;
-      Renamings         : Boolean          := False;
-      With_Node         : Node_Id          := Empty;
-      PMES              : Boolean          := False) return Unit_Number_Type
+     (Load_Name  : Unit_Name_Type;
+      Required   : Boolean;
+      Error_Node : Node_Id;
+      Subunit    : Boolean;
+      Corr_Body  : Unit_Number_Type := No_Unit;
+      Renamings  : Boolean          := False;
+      With_Node  : Node_Id          := Empty;
+      PMES       : Boolean          := False) return Unit_Number_Type
    is
       Calling_Unit : Unit_Number_Type;
       Uname_Actual : Unit_Name_Type;
diff --git a/gcc/ada/lib.adb b/gcc/ada/lib.adb
index 31a6b8c4c58..44aa5c61e60 100644
--- a/gcc/ada/lib.adb
+++ b/gcc/ada/lib.adb
@@ -128,12 +128,12 @@ package body Lib is
       return Units.Table (U).Is_Predefined_Renaming;
    end Is_Predefined_Renaming;
 
-   function Is_Internal_Unit       (U : Unit_Number_Type) return Boolean is
+   function Is_Internal_Unit (U : Unit_Number_Type) return Boolean is
    begin
       return Units.Table (U).Is_Internal_Unit;
    end Is_Internal_Unit;
 
-   function Is_Predefined_Unit     (U : Unit_Number_Type) return Boolean is
+   function Is_Predefined_Unit (U : Unit_Number_Type) return Boolean is
    begin
       return Units.Table (U).Is_Predefined_Unit;
    end Is_Predefined_Unit;
@@ -482,18 +482,12 @@ package body Lib is
          --  body of the same unit. The location in the spec is considered
          --  earlier.
 
-         if Nkind (Unit1) = N_Subprogram_Body
-              or else
-            Nkind (Unit1) = N_Package_Body
-         then
+         if Nkind (Unit1) in N_Subprogram_Body | N_Package_Body then
             if Library_Unit (Cunit (Unum1)) = Cunit (Unum2) then
                return Yes_After;
             end if;
 
-         elsif Nkind (Unit2) = N_Subprogram_Body
-                 or else
-               Nkind (Unit2) = N_Package_Body
-         then
+         elsif Nkind (Unit2) in N_Subprogram_Body | N_Package_Body then
             if Library_Unit (Cunit (Unum2)) = Cunit (Unum1) then
                return Yes_Before;
             end if;
diff --git a/gcc/ada/par-ch10.adb b/gcc/ada/par-ch10.adb
index e140626f668..9a49d45b8ab 100644
--- a/gcc/ada/par-ch10.adb
+++ b/gcc/ada/par-ch10.adb
@@ -555,7 +555,7 @@ package body Ch10 is
                                   | N_Generic_Function_Renaming_Declaration
                                   | N_Generic_Package_Renaming_Declaration
                                   | N_Generic_Procedure_Renaming_Declaration
-          or else Nkind (Unit_Node) in N_Package_Body
+                                  | N_Package_Body
                                   | N_Package_Instantiation
                                   | N_Package_Renaming_Declaration
                                   | N_Package_Specification
diff --git a/gcc/ada/par-load.adb b/gcc/ada/par-load.adb
index 05e9f9edea8..fe8fede714c 100644
--- a/gcc/ada/par-load.adb
+++ b/gcc/ada/par-load.adb
@@ -182,14 +182,8 @@ begin
       --  Check for predefined file case
 
       if Name_Len > 1
+        and then Name_Buffer (1) in 'a' | 's' | 'i' | 'g'
         and then Name_Buffer (2) = '-'
-        and then (Name_Buffer (1) = 'a'
-                    or else
-                  Name_Buffer (1) = 's'
-                    or else
-                  Name_Buffer (1) = 'i'
-                    or else
-                  Name_Buffer (1) = 'g')
       then
          declare
             Expect_Name : constant Unit_Name_Type := Expected_Unit (Cur_Unum);
@@ -248,9 +242,7 @@ begin
 
    --  If current unit is a body, load its corresponding spec
 
-   if Nkind (Unit (Curunit)) = N_Package_Body
-     or else Nkind (Unit (Curunit)) = N_Subprogram_Body
-   then
+   if Nkind (Unit (Curunit)) in N_Package_Body | N_Subprogram_Body then
       Spec_Name := Get_Spec_Name (Unit_Name (Cur_Unum));
       Unum :=
         Load_Unit
@@ -304,11 +296,11 @@ begin
    --  If current unit is a child unit spec, load its parent. If the child unit
    --  is loaded through a limited with, the parent must be as well.
 
-   elsif     Nkind (Unit (Curunit)) =  N_Package_Declaration
-     or else Nkind (Unit (Curunit)) =  N_Subprogram_Declaration
-     or else Nkind (Unit (Curunit)) in N_Generic_Declaration
-     or else Nkind (Unit (Curunit)) in N_Generic_Instantiation
-     or else Nkind (Unit (Curunit)) in N_Renaming_Declaration
+   elsif Nkind (Unit (Curunit)) in N_Package_Declaration
+                                 | N_Subprogram_Declaration
+                                 | N_Generic_Declaration
+                                 | N_Generic_Instantiation
+                                 | N_Renaming_Declaration
    then
       --  Turn style checks off for parent unit
 
diff --git a/gcc/ada/uname.adb b/gcc/ada/uname.adb
index ca937efae38..3192c3da6d2 100644
--- a/gcc/ada/uname.adb
+++ b/gcc/ada/uname.adb
@@ -367,8 +367,8 @@ package body Uname is
          Node := Declaration_Node (Entity (Node));
       end if;
 
-      if Nkind (Node) = N_Package_Specification
-        or else Nkind (Node) in N_Subprogram_Specification
+      if Nkind (Node) in N_Package_Specification
+                       | N_Subprogram_Specification
       then
          Node := Parent (Node);
       end if;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-06 14:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-06 14:49 [gcc r12-2073] [Ada] Simplify unit loading with membership tests Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).