From 0c25b7838090b7ff130b74b22b00ab09d59a5dd2 Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Tue, 17 Mar 2020 16:58:24 +0100 Subject: [PATCH] [Ada] Avoid "others => <>" association in resolved record aggregates 2020-06-11 Piotr Trojanek gcc/ada/ * sem_aggr.adb (Add_Association): Add assertion about the formal parameters. (Propagate_Discriminants): Always add an explicit component association, so that an "others => <>" association is never needed. --- gcc/ada/sem_aggr.adb | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index b80810dffad..a0f878442f4 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -3393,6 +3393,8 @@ package body Sem_Aggr is -- If this is a box association the expression is missing, so use the -- Sloc of the aggregate itself for the new association. + pragma Assert (Present (Expr) xor Is_Box_Present); + if Present (Expr) then Loc := Sloc (Expr); else @@ -3804,8 +3806,6 @@ package body Sem_Aggr is is Loc : constant Source_Ptr := Sloc (N); - Needs_Box : Boolean := False; - procedure Process_Component (Comp : Entity_Id); -- Add one component with a box association to the inner aggregate, -- and recurse if component is itself composite. @@ -3834,7 +3834,9 @@ package body Sem_Aggr is Build_Constrained_Itype (New_Aggr, T, Component_Associations (New_Aggr)); else - Needs_Box := True; + Add_Association + (Comp, Empty, Component_Associations (Aggr), + Is_Box_Present => True); end if; end Process_Component; @@ -3885,14 +3887,6 @@ package body Sem_Aggr is Next_Component (Comp); end loop; end if; - - if Needs_Box then - Append_To (Component_Associations (Aggr), - Make_Component_Association (Loc, - Choices => New_List (Make_Others_Choice (Loc)), - Expression => Empty, - Box_Present => True)); - end if; end Propagate_Discriminants; ----------------------- -- 2.30.2