[COMMITTED,21/31] ada: Remove dead code in detection of null record definitions

Message ID 20250107125350.619654-21-poulhies@adacore.com
State New
Headers
Series [COMMITTED,01/31] ada: Restrict previous change made to expansion of allocators |

Commit Message

Marc Poulhiès Jan. 7, 2025, 12:53 p.m. UTC
  From: Piotr Trojanek <trojanek@adacore.com>

Code cleanup; behavior is unaffected.

gcc/ada/ChangeLog:

	* sem_util.adb (Is_Null_Record_Definition): Remove check for
	Component_List being present after using it; replace check for
	component item being a component declaration with an assertion;
	fix style in comment.

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

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

Patch

diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index a11afa8be2d..55e9979a215 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -18984,22 +18984,19 @@  package body Sem_Util is
    function Is_Null_Record_Definition (Record_Def : Node_Id) return Boolean is
       Item : Node_Id;
    begin
-      --  Testing Null_Present is just an optimization, not required.
+      --  Testing Null_Present is just an optimization, not required
 
       if Null_Present (Record_Def) then
          return True;
       elsif Present (Variant_Part (Component_List (Record_Def))) then
          return False;
-      elsif No (Component_List (Record_Def)) then
-         return True;
       end if;
 
       Item := First_Non_Pragma (Component_Items (Component_List (Record_Def)));
 
       while Present (Item) loop
-         if Nkind (Item) = N_Component_Declaration
-           and then Is_Internal_Name (Chars (Defining_Identifier (Item)))
-         then
+         pragma Assert (Nkind (Item) = N_Component_Declaration);
+         if Is_Internal_Name (Chars (Defining_Identifier (Item))) then
             null;
          else
             return False;