aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2018-05-28 08:55:47 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-05-28 08:55:47 +0000
commit4fd9587f7c4b77550b6a9a1045e2687fb5d77335 (patch)
treebf0df013ecdb5857a99d11f9c5679121b2fd556b /gcc
parent04920bb67f9d7014248beed823a6a4ac50dbedd4 (diff)
downloadgcc-4fd9587f7c4b77550b6a9a1045e2687fb5d77335.zip
gcc-4fd9587f7c4b77550b6a9a1045e2687fb5d77335.tar.gz
gcc-4fd9587f7c4b77550b6a9a1045e2687fb5d77335.tar.bz2
[Ada] Improve unnesting for discriminants of record subtypes
2018-05-28 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * exp_unst.adb (Check_Static_Type): For a record subtype, check discriminant constraints as well. (Visit_Node): For a selected component, check type of prefix, as is done for indexed components and slices. From-SVN: r260838
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog7
-rw-r--r--gcc/ada/exp_unst.adb31
2 files changed, 37 insertions, 1 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index c00a76d..f6689b5 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,10 @@
+2018-05-28 Ed Schonberg <schonberg@adacore.com>
+
+ * exp_unst.adb (Check_Static_Type): For a record subtype, check
+ discriminant constraints as well.
+ (Visit_Node): For a selected component, check type of prefix, as is
+ done for indexed components and slices.
+
2018-05-28 Javier Miranda <miranda@adacore.com>
* exp_ch4.adb (Real_Range_Check): Add a temporary to store the integer
diff --git a/gcc/ada/exp_unst.adb b/gcc/ada/exp_unst.adb
index e2ecafc..f6d7650 100644
--- a/gcc/ada/exp_unst.adb
+++ b/gcc/ada/exp_unst.adb
@@ -481,17 +481,34 @@ package body Exp_Unst is
end if;
end;
- -- For record type, check all components
+ -- For record type, check all components and discriminant
+ -- constraints if present.
elsif Is_Record_Type (T) then
declare
C : Entity_Id;
+ D : Elmt_Id;
+
begin
C := First_Component_Or_Discriminant (T);
while Present (C) loop
Check_Static_Type (Etype (C), N, DT);
Next_Component_Or_Discriminant (C);
end loop;
+
+ if Has_Discriminants (T)
+ and then Present (Discriminant_Constraint (T))
+ then
+ D := First_Elmt (Discriminant_Constraint (T));
+ while Present (D) loop
+ if not Is_Static_Expression (Node (D)) then
+ Note_Uplevel_Bound (Node (D), N);
+ DT := True;
+ end if;
+
+ Next_Elmt (D);
+ end loop;
+ end if;
end;
-- For array type, check index types and component type
@@ -685,6 +702,18 @@ package body Exp_Unst is
Check_Static_Type (Etype (Prefix (N)), Empty, DT);
end;
+ -- A selected component can have an implicit up-level reference
+ -- due to the bounds of previous fields in the record. We
+ -- simplify the processing here by examining all components
+ -- of the record.
+
+ elsif Nkind (N) = N_Selected_Component then
+ declare
+ DT : Boolean := False;
+ begin
+ Check_Static_Type (Etype (Prefix (N)), Empty, DT);
+ end;
+
-- Record a subprogram. We record a subprogram body that acts as
-- a spec. Otherwise we record a subprogram declaration, providing
-- that it has a corresponding body we can get hold of. The case