diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2024-07-16 16:07:59 +0200 |
---|---|---|
committer | Marc Poulhiès <dkm@gcc.gnu.org> | 2024-08-02 09:08:10 +0200 |
commit | d8a27bb9a7d932b3a3f8b1ffc9e156f698d08aee (patch) | |
tree | 018e87d7d72cdd9f54f5f411f62f006da42a851a /gcc/ada | |
parent | 637b27b98076d8857aa62655bbb815a39f8f68bc (diff) | |
download | gcc-d8a27bb9a7d932b3a3f8b1ffc9e156f698d08aee.zip gcc-d8a27bb9a7d932b3a3f8b1ffc9e156f698d08aee.tar.gz gcc-d8a27bb9a7d932b3a3f8b1ffc9e156f698d08aee.tar.bz2 |
ada: Fix handling of iterated component associations with sub-aggregates
Fix a number of problems in handling of actions generated for a
2-dimensional array aggregate where the outer aggregate has iterated
component association and the inner aggregate involves run-time checks.
gcc/ada/
* exp_aggr.adb (Add_Loop_Actions): Actions are now attached to
iterated component association just like they are attached to
ordinary component association.
(Build_Array_Aggr_Code): If resolution of the array aggregate
generated some actions, e.g. for run-time checks, then we must
keep them; same for the Other_Clause.
* sem_aggr.adb (Resolve_Iterated_Component_Association): Unset
references to iterator variable in loop actions (which might come
from run-time check), just these references are unset in the
expression itself.
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/exp_aggr.adb | 14 | ||||
-rw-r--r-- | gcc/ada/sem_aggr.adb | 9 |
2 files changed, 20 insertions, 3 deletions
diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 8496fcd..aa6079d 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -1259,7 +1259,8 @@ package body Exp_Aggr is if No (Expr) then return Lis; - elsif Nkind (Parent (Expr)) = N_Component_Association + elsif Nkind (Parent (Expr)) in N_Component_Association + | N_Iterated_Component_Association and then Present (Loop_Actions (Parent (Expr))) then Res := Loop_Actions (Parent (Expr)); @@ -1962,7 +1963,9 @@ package body Exp_Aggr is Bounds := Get_Index_Bounds (Choice); - if Low /= High then + if Low /= High + and then No (Loop_Actions (Assoc)) + then Set_Loop_Actions (Assoc, New_List); end if; @@ -2038,7 +2041,12 @@ package body Exp_Aggr is if First or else not Empty_Range (Low, High) then First := False; - Set_Loop_Actions (Others_Assoc, New_List); + if Present (Loop_Actions (Others_Assoc)) then + pragma Assert + (Is_Empty_List (Loop_Actions (Others_Assoc))); + else + Set_Loop_Actions (Others_Assoc, New_List); + end if; Expr := Get_Assoc_Expr (Others_Assoc); Append_List (Gen_Loop (Low, High, Expr), To => New_Code); end if; diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index 656d789..087e324 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -2212,6 +2212,15 @@ package body Sem_Aggr is if Operating_Mode /= Check_Semantics then Remove_References (Expr); + declare + Loop_Action : Node_Id; + begin + Loop_Action := First (Loop_Actions (N)); + while Present (Loop_Action) loop + Remove_References (Loop_Action); + Next (Loop_Action); + end loop; + end; end if; -- An iterated_component_association may appear in a nested |