diff options
author | Ronan Desplanques <desplanques@adacore.com> | 2024-07-15 10:22:29 +0200 |
---|---|---|
committer | Marc Poulhiès <dkm@gcc.gnu.org> | 2024-08-02 09:08:08 +0200 |
commit | 54acd24d5f82766e7ad43a41519b00369ae46863 (patch) | |
tree | 8ea2446f497342a180cc289f93df3278b1a4f295 | |
parent | 425eceb75d09f3fa228c3e26c5136ce0d688fbcf (diff) | |
download | gcc-54acd24d5f82766e7ad43a41519b00369ae46863.zip gcc-54acd24d5f82766e7ad43a41519b00369ae46863.tar.gz gcc-54acd24d5f82766e7ad43a41519b00369ae46863.tar.bz2 |
ada: Tweak container aggregate expansion code
This patch makes a minor modification to Expand_Container_Aggregate
in order to silence a GNAT SAS false positive.
gcc/ada/
* exp_aggr.adb (Expand_Container_Aggregate): Remove variables.
(To_Int): New function.
(Add_Range_Size): Use newly introduced function.
-rw-r--r-- | gcc/ada/exp_aggr.adb | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 59ed75e..ed0dad1 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -6642,8 +6642,6 @@ package body Exp_Aggr is Choice_Lo : Node_Id := Empty; Choice_Hi : Node_Id := Empty; - Int_Choice_Lo : Int; - Int_Choice_Hi : Int; Is_Indexed_Aggregate : Boolean := False; @@ -6696,32 +6694,38 @@ package body Exp_Aggr is -------------------- procedure Add_Range_Size is - Range_Int_Lo : Int; - Range_Int_Hi : Int; + function To_Int (Expr : N_Subexpr_Id) return Int; + -- Return the Int value corresponding to the bound Expr - begin - -- The bounds of the discrete range are integers or enumeration - -- literals + ------------ + -- To_Int -- + ------------ - if Nkind (Lo) = N_Integer_Literal then - Range_Int_Lo := UI_To_Int (Intval (Lo)); - Range_Int_Hi := UI_To_Int (Intval (Hi)); + function To_Int (Expr : N_Subexpr_Id) return Int is + begin + -- The bounds of the discrete range are integers or enumeration + -- literals + return UI_To_Int + ((if Nkind (Expr) = N_Integer_Literal then + Intval (Expr) + else + Enumeration_Pos (Expr))); + end To_Int; - else - Range_Int_Lo := UI_To_Int (Enumeration_Pos (Lo)); - Range_Int_Hi := UI_To_Int (Enumeration_Pos (Hi)); - end if; + -- Local variables + + Range_Int_Lo : constant Int := To_Int (Lo); + Range_Int_Hi : constant Int := To_Int (Hi); + begin Siz := Siz + Range_Int_Hi - Range_Int_Lo + 1; - if No (Choice_Lo) or else Range_Int_Lo < Int_Choice_Lo then + if No (Choice_Lo) or else Range_Int_Lo < To_Int (Choice_Lo) then Choice_Lo := Lo; - Int_Choice_Lo := Range_Int_Lo; end if; - if No (Choice_Hi) or else Range_Int_Hi > Int_Choice_Hi then + if No (Choice_Hi) or else Range_Int_Hi > To_Int (Choice_Hi) then Choice_Hi := Hi; - Int_Choice_Hi := Range_Int_Hi; end if; end Add_Range_Size; |