aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2020-05-02 17:45:21 +0200
committerGiuliano Belinassi <giuliano.belinassi@usp.br>2020-08-17 13:14:11 -0300
commitfc59859ce2c9b93ba34bb21153ba8ea4d7de4554 (patch)
tree29df84b0478ad7c6c7193e4a23bf6b0c6f6daf55 /gcc
parent549c4c7f541119f6f930d6ef18b96b889bfab2a8 (diff)
downloadgcc-fc59859ce2c9b93ba34bb21153ba8ea4d7de4554.zip
gcc-fc59859ce2c9b93ba34bb21153ba8ea4d7de4554.tar.gz
gcc-fc59859ce2c9b93ba34bb21153ba8ea4d7de4554.tar.bz2
[Ada] Fix check for bounds in aggregate expansion of allocator
2020-06-19 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * exp_aggr.adb (In_Place_Assign_OK): In an allocator context, check the bounds of an array aggregate against those of the designated type, except if the latter is unconstrained.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/exp_aggr.adb21
1 files changed, 16 insertions, 5 deletions
diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb
index 22ed3ae..95f0dda 100644
--- a/gcc/ada/exp_aggr.adb
+++ b/gcc/ada/exp_aggr.adb
@@ -4429,15 +4429,26 @@ package body Exp_Aggr is
then
Aggr_In := First_Index (Etype (N));
+ -- Context is an assignment
+
if Parent_Kind = N_Assignment_Statement then
Obj_In := First_Index (Etype (Name (Parent_Node)));
- else
- -- Context is an allocator. Check bounds of aggregate against
- -- given type in qualified expression.
+ -- Context is an allocator. Check the bounds of the aggregate against
+ -- those of the designated type, except in the case where the type is
+ -- unconstrained (and then we can directly return true, see below).
+
+ else pragma Assert (Parent_Kind = N_Allocator);
+ declare
+ Desig_Typ : constant Entity_Id :=
+ Designated_Type (Etype (Parent_Node));
+ begin
+ if not Is_Constrained (Desig_Typ) then
+ return True;
+ end if;
- pragma Assert (Parent_Kind = N_Allocator);
- Obj_In := First_Index (Etype (Entity (Subtype_Mark (Parent (N)))));
+ Obj_In := First_Index (Desig_Typ);
+ end;
end if;
while Present (Aggr_In) loop