[COMMITTED] ada: Remove redundant protection against empty lists

Message ID 20230515094346.1408423-1-poulhies@adacore.com
State Accepted
Headers
Series [COMMITTED] ada: Remove redundant protection against empty lists |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Marc Poulhiès May 15, 2023, 9:43 a.m. UTC
  From: Piotr Trojanek <trojanek@adacore.com>

Calls to First on No_List intentionally return Empty node, so explicit
guards against No_List are unnecessary. Code cleanup; semantics is
unaffected.

gcc/ada/

	* sem_util.adb (New_Copy_Tree): Remove redundant calls to Present.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/sem_util.adb | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
  

Patch

diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 5ec0140d090..eb0d08a1851 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -24167,14 +24167,12 @@  package body Sem_Util is
          --  Note that the element of a syntactic list is always a node, never
          --  an entity or itype, hence the call to Visit_Node.
 
-         if Present (List) then
-            Elmt := First (List);
-            while Present (Elmt) loop
-               Visit_Node (Elmt);
+         Elmt := First (List);
+         while Present (Elmt) loop
+            Visit_Node (Elmt);
 
-               Next (Elmt);
-            end loop;
-         end if;
+            Next (Elmt);
+         end loop;
       end Visit_List;
 
       ----------------
@@ -24206,8 +24204,7 @@  package body Sem_Util is
          --  If the node is a block, we need to process all declarations
          --  in the block and make new entities for each.
 
-         if Nkind (N) = N_Block_Statement and then Present (Declarations (N))
-         then
+         if Nkind (N) = N_Block_Statement then
             declare
                Decl : Node_Id := First (Declarations (N));