aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2018-05-22 13:23:51 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-05-22 13:23:51 +0000
commitfbb539954efc29574ff0a8399d88d6525a35c17a (patch)
tree4cc8305fdeadf9ca63282da3036cf691be1f49d6 /gcc/ada
parent651822aec7caa0ed1aa8cb3dfb07a380b4595b08 (diff)
downloadgcc-fbb539954efc29574ff0a8399d88d6525a35c17a.zip
gcc-fbb539954efc29574ff0a8399d88d6525a35c17a.tar.gz
gcc-fbb539954efc29574ff0a8399d88d6525a35c17a.tar.bz2
[Ada] Crash with private types and renamed discriminants
This patch fixes a compiler abort on an object declaration whose type is a private type with discriminants, and whose full view is a derived type that renames some discriminant of its parent. 2018-05-22 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * sem_ch3.adb (Search_Derivation_Levels): Whenever a parent type is private, use the full view if available, because it may include renamed discriminants whose values are stored in the corresponding Stored_Constraint. gcc/testsuite/ * gnat.dg/discr49.adb, gnat.dg/discr49_rec1.adb, gnat.dg/discr49_rec1.ads, gnat.dg/discr49_rec2.adb, gnat.dg/discr49_rec2.ads: New testcase. From-SVN: r260521
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog7
-rw-r--r--gcc/ada/sem_ch3.adb12
2 files changed, 18 insertions, 1 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 37615e9..c0b1989 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,12 @@
2018-05-22 Ed Schonberg <schonberg@adacore.com>
+ * sem_ch3.adb (Search_Derivation_Levels): Whenever a parent type is
+ private, use the full view if available, because it may include renamed
+ discriminants whose values are stored in the corresponding
+ Stored_Constraint.
+
+2018-05-22 Ed Schonberg <schonberg@adacore.com>
+
* einfo.ads, einfo.adb: New attribute Hidden_In_Formal_Instance,
defined on packages that are actuals for formal packages, in order to
set/reset the visibility of the formals of a formal package with given
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 2f8af66..994562d 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -17977,9 +17977,19 @@ package body Sem_Ch3 is
Search_Derivation_Levels (Ti, Stored_Constraint (Ti), True);
else
declare
- Td : constant Entity_Id := Etype (Ti);
+ Td : Entity_Id := Etype (Ti);
begin
+
+ -- If the parent type is private, the full view may include
+ -- renamed discriminants, and it is those stored values
+ -- that may be needed (the partial view never has more
+ -- information than the full view).
+
+ if Is_Private_Type (Td) and then Present (Full_View (Td)) then
+ Td := Full_View (Td);
+ end if;
+
if Td = Ti then
Result := Discriminant;