]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Remove redundant protection against empty lists
authorPiotr Trojanek <trojanek@adacore.com>
Wed, 8 Jun 2022 14:58:18 +0000 (16:58 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 5 Jul 2022 08:28:20 +0000 (08:28 +0000)
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/

* exp_code.adb (Setup_Asm_IO_Args): Remove guard against No_List.
* par_sco.adb (Process_Decisions): Likewise.
* sem_ch13.adb (Check_Component_List): Likewise.
* sem_ch6.adb (FCL): Likewise.

gcc/ada/exp_code.adb
gcc/ada/par_sco.adb
gcc/ada/sem_ch13.adb
gcc/ada/sem_ch6.adb

index 11fbc5fc29df335828ce3cb557c574a815a1eb09..d144b489f2f5f74347b4e09fa624ee4ed9eedca1 100644 (file)
@@ -471,11 +471,7 @@ package body Exp_Code is
       --  Case of list of arguments
 
       elsif Nkind (Arg) = N_Aggregate then
-         if Expressions (Arg) = No_List then
-            Operand_Var := Empty;
-         else
-            Operand_Var := First (Expressions (Arg));
-         end if;
+         Operand_Var := First (Expressions (Arg));
 
       --  Otherwise must be default (no operands) case
 
index aba863dfeb2337cc1d6987d4505f861fb6eaaa3f..e8875cf28b4fdfabce66768fedfc400d7f05c0c8 100644 (file)
@@ -480,13 +480,11 @@ package body Par_SCO is
       N : Node_Id;
 
    begin
-      if L /= No_List then
-         N := First (L);
-         while Present (N) loop
-            Process_Decisions (N, T, Pragma_Sloc);
-            Next (N);
-         end loop;
-      end if;
+      N := First (L);
+      while Present (N) loop
+         Process_Decisions (N, T, Pragma_Sloc);
+         Next (N);
+      end loop;
    end Process_Decisions;
 
    --  Version taking a node
index 27f325049993c35e7d0cecc6c7b10822e25c4294..bb654abe412ae87a3a4dc6064303fd9ff9401434 100644 (file)
@@ -12135,24 +12135,22 @@ package body Sem_Ch13 is
             begin
                --  Gather discriminants into Comp
 
-               if DS /= No_List then
-                  Citem := First (DS);
-                  while Present (Citem) loop
-                     if Nkind (Citem) = N_Discriminant_Specification then
-                        declare
-                           Ent : constant Entity_Id :=
-                                   Defining_Identifier (Citem);
-                        begin
-                           if Ekind (Ent) = E_Discriminant then
-                              Ncomps := Ncomps + 1;
-                              Comps (Ncomps) := Ent;
-                           end if;
-                        end;
-                     end if;
+               Citem := First (DS);
+               while Present (Citem) loop
+                  if Nkind (Citem) = N_Discriminant_Specification then
+                     declare
+                        Ent : constant Entity_Id :=
+                                Defining_Identifier (Citem);
+                     begin
+                        if Ekind (Ent) = E_Discriminant then
+                           Ncomps := Ncomps + 1;
+                           Comps (Ncomps) := Ent;
+                        end if;
+                     end;
+                  end if;
 
-                     Next (Citem);
-                  end loop;
-               end if;
+                  Next (Citem);
+               end loop;
 
                --  Gather component entities into Comp
 
index e5c13ed36b25ee7fd9342457788139c9f9d28532..440770ad8bf2c0fac5aacea47b616b5fa1b0369b 100644 (file)
@@ -9988,17 +9988,8 @@ package body Sem_Ch6 is
          N2 : Node_Id;
 
       begin
-         if L1 = No_List then
-            N1 := Empty;
-         else
-            N1 := First (L1);
-         end if;
-
-         if L2 = No_List then
-            N2 := Empty;
-         else
-            N2 := First (L2);
-         end if;
+         N1 := First (L1);
+         N2 := First (L2);
 
          --  Compare two lists, skipping rewrite insertions (we want to compare
          --  the original trees, not the expanded versions).