]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Remove dead code in detection of null record definitions
authorPiotr Trojanek <trojanek@adacore.com>
Thu, 19 Dec 2024 14:32:56 +0000 (15:32 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 7 Jan 2025 12:33:34 +0000 (13:33 +0100)
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.

gcc/ada/sem_util.adb

index a11afa8be2d37ed2e638798095613d5d03388757..55e9979a21554c4506902cfb325472d81631bcdc 100644 (file)
@@ -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;