[COMMITTED] ada: Remove redundant protection against empty lists

Message ID 20230529082944.2410880-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 29, 2023, 8:29 a.m. UTC
  From: Piotr Trojanek <trojanek@adacore.com>

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

gcc/ada/

	* sem_util.adb (Check_Function_Writable_Actuals): Remove guard against
	a membership test with no alternatives; simplify with a membership test.

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

---
 gcc/ada/sem_util.adb | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
  

Patch

diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index a42b2dff60f..34ea06432cf 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -2882,9 +2882,7 @@  package body Sem_Util is
                   Collect_Identifiers (Right_Opnd (N));
                end if;
 
-               if Nkind (N) in N_In | N_Not_In
-                 and then Present (Alternatives (N))
-               then
+               if Nkind (N) in N_Membership_Test then
                   Expr := First (Alternatives (N));
                   while Present (Expr) loop
                      Collect_Identifiers (Expr);