aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2020-03-17 16:58:24 +0100
committerGiuliano Belinassi <giuliano.belinassi@usp.br>2020-08-17 13:12:10 -0300
commitabffcd2996d5a63fb682d88044a7acaafea23cf7 (patch)
tree66561be9f167747589c4634bb5af9def8ee4427d
parent560cda43b517a0ced6019b57fe09b3c8300dd2bf (diff)
downloadgcc-abffcd2996d5a63fb682d88044a7acaafea23cf7.zip
gcc-abffcd2996d5a63fb682d88044a7acaafea23cf7.tar.gz
gcc-abffcd2996d5a63fb682d88044a7acaafea23cf7.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.
-rw-r--r--gcc/ada/sem_aggr.adb16
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;
-----------------------