[COMMITTED,21/26] ada: Simplify code by reusing Choice_List

Message ID 20240802071210.413366-21-poulhies@adacore.com
State Committed
Commit 4d9dfa0082ee46ce969283fafe67b2008ab661fc
Headers
Series [COMMITTED,01/26] ada: Fix detection of suspicious loop patterns |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 fail Patch failed to apply

Commit Message

Marc Poulhiès Aug. 2, 2024, 7:11 a.m. UTC
  From: Piotr Trojanek <trojanek@adacore.com>

Code cleanup; semantics is unaffected.

gcc/ada/

	* exp_aggr.adb (Gen_Assign): Fix layout.
	* sem_aggr.adb (Empty_Range): Reuse Choice_List.

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

---
 gcc/ada/exp_aggr.adb | 8 ++++----
 gcc/ada/sem_aggr.adb | 8 +-------
 2 files changed, 5 insertions(+), 11 deletions(-)
  

Patch

diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb
index 25af78a4da7..7a2d0570dbd 100644
--- a/gcc/ada/exp_aggr.adb
+++ b/gcc/ada/exp_aggr.adb
@@ -1010,8 +1010,8 @@  package body Exp_Aggr is
       --  Returns a new reference to the index type name
 
       function Gen_Assign
-        (Ind     : Node_Id;
-         Expr    : Node_Id) return List_Id;
+        (Ind  : Node_Id;
+         Expr : Node_Id) return List_Id;
       --  Ind must be a side-effect-free expression. If the input aggregate N
       --  to Build_Loop contains no subaggregates, then this function returns
       --  the assignment statement:
@@ -1237,8 +1237,8 @@  package body Exp_Aggr is
       ----------------
 
       function Gen_Assign
-        (Ind     : Node_Id;
-         Expr    : Node_Id) return List_Id
+        (Ind  : Node_Id;
+         Expr : Node_Id) return List_Id
        is
          function Add_Loop_Actions (Lis : List_Id) return List_Id;
          --  Collect insert_actions generated in the construction of a loop,
diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
index 565f2cb8a79..656d789de73 100644
--- a/gcc/ada/sem_aggr.adb
+++ b/gcc/ada/sem_aggr.adb
@@ -2735,15 +2735,9 @@  package body Sem_Aggr is
             -----------------
 
             function Empty_Range (A : Node_Id) return Boolean is
-               R : Node_Id;
+               R : constant Node_Id := First (Choice_List (A));
 
             begin
-               if Nkind (A) = N_Iterated_Component_Association then
-                  R := First (Discrete_Choices (A));
-               else
-                  R := First (Choices (A));
-               end if;
-
                return No (Next (R))
                  and then Nkind (R) = N_Range
                  and then Compile_Time_Compare