From: Ed Schonberg Date: Mon, 21 Sep 2020 15:54:09 +0000 (-0400) Subject: [Ada] Handle Iterated_Component_Association with Others_Choice X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=02a8253980d04638085237915498acd04297fbbf;p=gcc.git [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. --- diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 469777f1b09..986ccc992a9 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;