From: Ed Schonberg Date: Fri, 8 May 2020 13:27:24 +0000 (-0400) Subject: [Ada] Crash on derived type with rep. clause and renamed discriminant X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e3bf5e2ef3d08a1fac9db2b5f0a1f107b25d67c5;p=gcc.git [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. --- diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb index a4916ef4af2..caacda6e6f0 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);