diff options
author | Ed Schonberg <schonberg@adacore.com> | 2020-09-21 11:54:09 -0400 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-10-26 04:59:17 -0400 |
commit | 02a8253980d04638085237915498acd04297fbbf (patch) | |
tree | 6f0950445bd23f6d410fb29858afceb870292355 /gcc | |
parent | fcae4f70cd2ccc91079df0e31d840dd43145b617 (diff) | |
download | gcc-02a8253980d04638085237915498acd04297fbbf.zip gcc-02a8253980d04638085237915498acd04297fbbf.tar.gz gcc-02a8253980d04638085237915498acd04297fbbf.tar.bz2 |
[Ada] Handle Iterated_Component_Association with Others_Choice
gcc/ada/
* exp_aggr.adb (Build_Array_Aggr_Code): If the aggregate
includes an Others_Choice in an association that is an
Iterated_Component_Association, generate a proper loop for it.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/exp_aggr.adb | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 469777f..986ccc9 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -2448,18 +2448,30 @@ package body Exp_Aggr is Next (Expr); end loop; - -- STEP 2 (b): Generate final loop if an others choice is present + -- STEP 2 (b): Generate final loop if an others choice is present. -- Here Nb_Elements gives the offset of the last positional element. if Present (Component_Associations (N)) then Assoc := Last (Component_Associations (N)); - -- Ada 2005 (AI-287) + if Nkind (Assoc) = N_Iterated_Component_Association then + -- Ada 2020: generate a loop to have a proper scope for + -- the identifier that typically appears in the expression. + -- The lower bound of the loop is the position after all + -- previous positional components. - Append_List (Gen_While (Add (Nb_Elements, To => Aggr_L), - Aggr_High, - Get_Assoc_Expr (Assoc)), -- AI-287 - To => New_Code); + Append_List (Gen_Loop (Add (Nb_Elements + 1, To => Aggr_L), + Aggr_High, + Expression (Assoc)), + To => New_Code); + else + -- Ada 2005 (AI-287) + + Append_List (Gen_While (Add (Nb_Elements, To => Aggr_L), + Aggr_High, + Get_Assoc_Expr (Assoc)), + To => New_Code); + end if; end if; end if; |