public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Piotr Trojanek <trojanek@adacore.com>
Subject: [Ada] Cleanup detection of No_Elist with No and Present
Date: Tue, 10 May 2022 08:21:07 +0000	[thread overview]
Message-ID: <20220510082107.GA3029224@adacore.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 436 bytes --]

Replace equality and inequality operators with calls to No and Present.
Offending occurrences found with:

$ grep -n " /\?= No_Elist" *.adb

Code cleanup only; semantics is unaffected.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* exp_ch11.adb, exp_ch5.adb, exp_prag.adb, gnat_cuda.adb,
	sem_ch12.adb, sem_ch3.adb, sem_ch6.adb, sem_util.adb,
	treepr.adb: Replace /= and = operators with No and Present,
	respectively.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 7117 bytes --]

diff --git a/gcc/ada/exp_ch11.adb b/gcc/ada/exp_ch11.adb
--- a/gcc/ada/exp_ch11.adb
+++ b/gcc/ada/exp_ch11.adb
@@ -813,7 +813,7 @@ package body Exp_Ch11 is
                   --  case we have to generate possible diagnostics.
 
                elsif Has_Local_Raise (Handler)
-                 and then Local_Raise_Statements (Handler) /= No_Elist
+                 and then Present (Local_Raise_Statements (Handler))
                then
                   Relmt := First_Elmt (Local_Raise_Statements (Handler));
                   while Present (Relmt) loop
@@ -1528,7 +1528,7 @@ package body Exp_Ch11 is
             H := Find_Local_Handler (Entity (Name (N)), N);
 
             if Present (H) then
-               if Local_Raise_Statements (H) = No_Elist then
+               if No (Local_Raise_Statements (H)) then
                   Set_Local_Raise_Statements (H, New_Elmt_List);
                end if;
 


diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb
--- a/gcc/ada/exp_ch5.adb
+++ b/gcc/ada/exp_ch5.adb
@@ -2101,7 +2101,7 @@ package body Exp_Ch5 is
             --  from the Rhs by selected component because they are invisible
             --  in the type of the right-hand side.
 
-            if Stored_Constraint (R_Typ) /= No_Elist then
+            if Present (Stored_Constraint (R_Typ)) then
                declare
                   Assign    : Node_Id;
                   Discr_Val : Elmt_Id;


diff --git a/gcc/ada/exp_prag.adb b/gcc/ada/exp_prag.adb
--- a/gcc/ada/exp_prag.adb
+++ b/gcc/ada/exp_prag.adb
@@ -1054,7 +1054,7 @@ package body Exp_Prag is
          Result : constant List_Id := New_List;
          Elmt   : Elmt_Id;
       begin
-         if Elmts = No_Elist then
+         if No (Elmts) then
             return Result;
          end if;
 


diff --git a/gcc/ada/gnat_cuda.adb b/gcc/ada/gnat_cuda.adb
--- a/gcc/ada/gnat_cuda.adb
+++ b/gcc/ada/gnat_cuda.adb
@@ -149,7 +149,7 @@ package body GNAT_CUDA is
    is
       Device_Entities : Elist_Id := Get_CUDA_Device_Entities (Pack_Id);
    begin
-      if Device_Entities = No_Elist then
+      if No (Device_Entities) then
          Device_Entities := New_Elmt_List;
          Set_CUDA_Device_Entities (Pack_Id, Device_Entities);
       end if;
@@ -166,7 +166,7 @@ package body GNAT_CUDA is
    is
       Kernels : Elist_Id := Get_CUDA_Kernels (Pack_Id);
    begin
-      if Kernels = No_Elist then
+      if No (Kernels) then
          Kernels := New_Elmt_List;
          Set_CUDA_Kernels (Pack_Id, Kernels);
       end if;
@@ -687,7 +687,7 @@ package body GNAT_CUDA is
    --  Start of processing for Build_And_Insert_CUDA_Initialization
 
    begin
-      if CUDA_Node_List = No_Elist then
+      if No (CUDA_Node_List) then
          return;
       end if;
 
@@ -745,7 +745,7 @@ package body GNAT_CUDA is
    begin
       pragma Assert (Debug_Flag_Underscore_C);
 
-      if Device_Entities = No_Elist then
+      if No (Device_Entities) then
          return;
       end if;
 
@@ -789,7 +789,7 @@ package body GNAT_CUDA is
       E       : Elist_Id)
    is
    begin
-      pragma Assert (Get_CUDA_Device_Entities (Pack_Id) = No_Elist);
+      pragma Assert (No (Get_CUDA_Device_Entities (Pack_Id)));
       CUDA_Device_Entities_Table.Set (Pack_Id, E);
    end Set_CUDA_Device_Entities;
 
@@ -802,7 +802,7 @@ package body GNAT_CUDA is
       Kernels : Elist_Id)
    is
    begin
-      pragma Assert (Get_CUDA_Kernels (Pack_Id) = No_Elist);
+      pragma Assert (No (Get_CUDA_Kernels (Pack_Id)));
       CUDA_Kernels_Table.Set (Pack_Id, Kernels);
    end Set_CUDA_Kernels;
 


diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb
--- a/gcc/ada/sem_ch12.adb
+++ b/gcc/ada/sem_ch12.adb
@@ -10224,7 +10224,7 @@ package body Sem_Ch12 is
       Prim      : Node_Id;
 
    begin
-      if Prims_List /= No_Elist then
+      if Present (Prims_List) then
          Prim_Elmt := First_Elmt (Prims_List);
          while Present (Prim_Elmt) loop
             Prim := Node (Prim_Elmt);


diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -5849,7 +5849,7 @@ package body Sem_Ch3 is
          --  Inherit Subprograms_For_Type from the full view, if present
 
          if Present (Full_View (T))
-           and then Subprograms_For_Type (Full_View (T)) /= No_Elist
+           and then Present (Subprograms_For_Type (Full_View (T)))
          then
             Set_Subprograms_For_Type
               (Id, Subprograms_For_Type (Full_View (T)));


diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -5473,11 +5473,11 @@ package body Sem_Ch6 is
       --  Restore the limited views in the spec, if any, to let the back end
       --  process it without running into circularities.
 
-      if Exch_Views /= No_Elist then
+      if Present (Exch_Views) then
          Restore_Limited_Views (Exch_Views);
       end if;
 
-      if Mask_Types /= No_Elist then
+      if Present (Mask_Types) then
          Unmask_Unfrozen_Types (Mask_Types);
       end if;
 


diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -3414,7 +3414,7 @@ package body Sem_Util is
                   end if;
 
                else
-                  if Identifiers_List = No_Elist then
+                  if No (Identifiers_List) then
                      Identifiers_List := New_Elmt_List;
                   end if;
 
@@ -3438,7 +3438,7 @@ package body Sem_Util is
             Elmt : Elmt_Id;
 
          begin
-            if List = No_Elist then
+            if No (List) then
                return False;
             end if;
 
@@ -3745,7 +3745,7 @@ package body Sem_Util is
 
                            Collect_Identifiers (Comp_Expr);
 
-                           if Writable_Actuals_List /= No_Elist then
+                           if Present (Writable_Actuals_List) then
 
                               --  As suggested by Robert, at current stage we
                               --  report occurrences of this case as warnings.
@@ -3908,7 +3908,7 @@ package body Sem_Util is
       --  Check violation of RM 6.20/3 in aggregates
 
       if Present (Aggr_Error_Node)
-        and then Writable_Actuals_List /= No_Elist
+        and then Present (Writable_Actuals_List)
       then
          Error_Msg_N
            ("value may be affected by call in other component because they "
@@ -3919,8 +3919,8 @@ package body Sem_Util is
 
       --  Check if some writable argument of a function is referenced
 
-      if Writable_Actuals_List /= No_Elist
-        and then Identifiers_List /= No_Elist
+      if Present (Writable_Actuals_List)
+        and then Present (Identifiers_List)
       then
          declare
             Elmt_1 : Elmt_Id;


diff --git a/gcc/ada/treepr.adb b/gcc/ada/treepr.adb
--- a/gcc/ada/treepr.adb
+++ b/gcc/ada/treepr.adb
@@ -539,7 +539,7 @@ package body Treepr is
          return;
       end if;
 
-      if E = No_Elist then
+      if No (E) then
          Write_Str ("<no elist>");
 
       elsif Is_Empty_Elmt_List (E) then



                 reply	other threads:[~2022-05-10  8:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220510082107.GA3029224@adacore.com \
    --to=derodat@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=trojanek@adacore.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).