diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2024-11-07 19:23:39 +0100 |
---|---|---|
committer | Marc Poulhiès <dkm@gcc.gnu.org> | 2024-11-18 15:06:55 +0100 |
commit | 1b24e30cabbe2d796dc12afbcccfe849b0b9eb92 (patch) | |
tree | a48069b9702942e494a250876ca466f3ef9b7d2e /gcc | |
parent | 3716d9887c9e4d8533b1a2346ac2025508f76ea4 (diff) | |
download | gcc-1b24e30cabbe2d796dc12afbcccfe849b0b9eb92.zip gcc-1b24e30cabbe2d796dc12afbcccfe849b0b9eb92.tar.gz gcc-1b24e30cabbe2d796dc12afbcccfe849b0b9eb92.tar.bz2 |
ada: Fix another minor fallout of previous changes to aggregate expansion
The processing of static array aggregates in Exp_Aggr requires that their
bounds be representable as Int(eger) values for practical purposes, and
the previous changes have exposed another path where this is not checked.
This introduces a UI_Are_In_Int_Range local predicate for convenience.
gcc/ada/ChangeLog:
* exp_aggr.adb (UI_Are_In_Int_Range): New predicate.
(Aggr_Size_OK): Use it.
(Flatten): Likewise.
(Packed_Array_Aggregate_Handled): Likewise.
(Static_Array_Aggregate): Likewise.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/exp_aggr.adb | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 1cfc97b..c34df84 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -161,6 +161,10 @@ package body Exp_Aggr is -- statement of variant part will usually be small and probably in near -- sorted order. + function UI_Are_In_Int_Range (Left, Right : Uint) return Boolean is + (UI_Is_In_Int_Range (Left) and then UI_Is_In_Int_Range (Right)); + -- Return True if both Left and Right are in Int range + ------------------------------------------------------ -- Local subprograms for Record Aggregate Expansion -- ------------------------------------------------------ @@ -777,10 +781,7 @@ package body Exp_Aggr is -- Bounds must be in integer range, for later array construction - if not UI_Is_In_Int_Range (Lov) - or else - not UI_Is_In_Int_Range (Hiv) - then + if not UI_Are_In_Int_Range (Lov, Hiv) then return False; end if; @@ -4504,13 +4505,13 @@ package body Exp_Aggr is -- present we can proceed since the bounds can be obtained from the -- aggregate. - if not Compile_Time_Known_Value (Blo) and then Others_Present - then + if not Compile_Time_Known_Value (Blo) and then Others_Present then return False; end if; - if not (UI_Is_In_Int_Range (Lov) and UI_Is_In_Int_Range (Hiv)) then - -- guard against raising C_E in UI_To_Int + -- Guard against raising C_E in UI_To_Int + + if not UI_Are_In_Int_Range (Lov, Hiv) then return False; end if; @@ -9100,17 +9101,15 @@ package body Exp_Aggr is end if; declare - Bounds_Vals : Range_Values; + Bounds_Vals : constant Range_Values := + (First => Expr_Value (Bounds.First), + Last => Expr_Value (Bounds.Last)); -- Compile-time known values of bounds - begin - -- Or are silly out of range of int bounds - Bounds_Vals.First := Expr_Value (Bounds.First); - Bounds_Vals.Last := Expr_Value (Bounds.Last); + begin + -- Guard against raising C_E in UI_To_Int - if not UI_Is_In_Int_Range (Bounds_Vals.First) - or else - not UI_Is_In_Int_Range (Bounds_Vals.Last) + if not UI_Are_In_Int_Range (Bounds_Vals.First, Bounds_Vals.Last) then return False; end if; @@ -9497,6 +9496,12 @@ package body Exp_Aggr is return False; end if; + -- Guard against raising C_E in UI_To_Int + + if not UI_Are_In_Int_Range (Intval (Lo), Intval (Hi)) then + return False; + end if; + -- Create a positional aggregate with the right number of -- copies of the expression. |