public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-4015] [Ada] Implementation of AI12-0212: iterator specs in array aggregates (II) Date: Fri, 1 Oct 2021 06:15:22 +0000 (GMT) [thread overview] Message-ID: <20211001061522.591203857C5E@sourceware.org> (raw) https://gcc.gnu.org/g:8b1a5da38e00348dfc359ef8418de344356ef78e commit r12-4015-g8b1a5da38e00348dfc359ef8418de344356ef78e Author: Ed Schonberg <schonberg@adacore.com> Date: Wed Aug 11 12:52:29 2021 -0400 [Ada] Implementation of AI12-0212: iterator specs in array aggregates (II) gcc/ada/ * exp_aggr.adb (Expand_Array_Aggregate, Two_Pass_Aggregate_Expansion): Increment index for element insertion within the loop, only if upper bound has not been reached. Diff: --- gcc/ada/exp_aggr.adb | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 461e4faac20..71bad3cb676 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -6504,6 +6504,18 @@ package body Exp_Aggr is Expressions => New_List (New_Occurrence_Of (Index_Id, Loc)))); + -- Add guard to skip last increment when upper bound is reached. + + Incr := Make_If_Statement (Loc, + Condition => + Make_Op_Ne (Loc, + Left_Opnd => New_Occurrence_Of (Index_Id, Loc), + Right_Opnd => + Make_Attribute_Reference (Loc, + Prefix => New_Occurrence_Of (Index_Type, Loc), + Attribute_Name => Name_Last)), + Then_Statements => New_List (Incr)); + One_Loop := Make_Loop_Statement (Loc, Iteration_Scheme => Make_Iteration_Scheme (Loc, @@ -6561,11 +6573,10 @@ package body Exp_Aggr is return; elsif Present (Component_Associations (N)) - and then - Nkind (First (Component_Associations (N))) - = N_Iterated_Component_Association - and then Present - (Iterator_Specification (First (Component_Associations (N)))) + and then Nkind (First (Component_Associations (N))) = + N_Iterated_Component_Association + and then + Present (Iterator_Specification (First (Component_Associations (N)))) then Two_Pass_Aggregate_Expansion (N); return; @@ -7389,7 +7400,7 @@ package body Exp_Aggr is elsif Nkind (Comp) = N_Iterated_Element_Association then return -1; - -- TBD : Create code for a loop and add to generated code, + -- ??? Need to create code for a loop and add to generated code, -- as is done for array aggregates with iterated element -- associations, instead of using Append operations.
reply other threads:[~2021-10-01 6:15 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211001061522.591203857C5E@sourceware.org \ --to=pmderodat@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).