[COMMITTED,30/30] ada: Fix small thinko in previous change to two-pass aggregate expansion

Message ID 20250106091819.474637-30-poulhies@adacore.com
State New
Headers
Series [COMMITTED,01/30] ada: Remove workaround for RM_Size being unable to represent unknown size |

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 Jan. 6, 2025, 9:18 a.m. UTC
  From: Eric Botcazou <ebotcazou@adacore.com>

We need a type tailored to the base index type to compute the length.

gcc/ada/ChangeLog:

	* exp_aggr.adb (Two_Pass_Aggregate_Expansion): Use the base type of
	the index type to find the type used to compute the length.

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

---
 gcc/ada/exp_aggr.adb | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Patch

diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb
index fb5cfc6d1f0..f771660d23a 100644
--- a/gcc/ada/exp_aggr.adb
+++ b/gcc/ada/exp_aggr.adb
@@ -5601,10 +5601,11 @@  package body Exp_Aggr is
          Comp_Type  : constant Entity_Id := Etype (N);
          Index_Id   : constant Entity_Id := Make_Temporary (Loc, 'I', N);
          Index_Type : constant Entity_Id := Etype (First_Index (Etype (N)));
+         Index_Base : constant Entity_Id := Base_Type (Index_Type);
          Size_Id    : constant Entity_Id := Make_Temporary (Loc, 'I', N);
          Size_Type  : constant Entity_Id :=
                         Integer_Type_For
-                          (Esize (Index_Type), Is_Unsigned_Type (Index_Type));
+                          (Esize (Index_Base), Is_Unsigned_Type (Index_Base));
          TmpE       : constant Entity_Id := Make_Temporary (Loc, 'A', N);
 
          Assoc    : Node_Id := First (Component_Associations (N));