diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2020-03-17 16:58:24 +0100 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-06-11 05:53:47 -0400 |
commit | 0c25b7838090b7ff130b74b22b00ab09d59a5dd2 (patch) | |
tree | ee83324880aa55730d09ea89fbfadcafd3dcbae2 /gcc | |
parent | d84eb7c511b163473c272f846905631fc4a66a52 (diff) | |
download | gcc-0c25b7838090b7ff130b74b22b00ab09d59a5dd2.zip gcc-0c25b7838090b7ff130b74b22b00ab09d59a5dd2.tar.gz gcc-0c25b7838090b7ff130b74b22b00ab09d59a5dd2.tar.bz2 |
[Ada] Avoid "others => <>" association in resolved record aggregates
2020-06-11 Piotr Trojanek <trojanek@adacore.com>
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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/sem_aggr.adb | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index b80810d..a0f8784 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; ----------------------- |