aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2020-05-08 09:27:24 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2020-07-06 07:35:12 -0400
commite3bf5e2ef3d08a1fac9db2b5f0a1f107b25d67c5 (patch)
tree56ccc83430de9e8a57a75ff600c8f1284dfbc933 /gcc
parentce16f54f6edf9c440046f6dd454e1dcbbb1ffae3 (diff)
downloadgcc-e3bf5e2ef3d08a1fac9db2b5f0a1f107b25d67c5.zip
gcc-e3bf5e2ef3d08a1fac9db2b5f0a1f107b25d67c5.tar.gz
gcc-e3bf5e2ef3d08a1fac9db2b5f0a1f107b25d67c5.tar.bz2
[Ada] Crash on derived type with rep. clause and renamed discriminant
gcc/ada/ * exp_ch5.adb (Find_Component): If the target type is a derived record type and the required component is a discriminant that is renamed in the derived type declaration, use the name of the original discriminant to locate the intended target component.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/exp_ch5.adb12
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb
index a4916ef..caacda6 100644
--- a/gcc/ada/exp_ch5.adb
+++ b/gcc/ada/exp_ch5.adb
@@ -1594,6 +1594,18 @@ package body Exp_Ch5 is
while Present (C) loop
if Chars (C) = Chars (Comp) then
return C;
+
+ -- The component may be a renamed discriminant, in
+ -- which case check against the name of the original
+ -- discriminant of the parent type.
+
+ elsif Is_Derived_Type (Scope (Comp))
+ and then Ekind (Comp) = E_Discriminant
+ and then Present (Corresponding_Discriminant (Comp))
+ and then
+ Chars (C) = Chars (Corresponding_Discriminant (Comp))
+ then
+ return C;
end if;
Next_Entity (C);