diff options
Diffstat (limited to 'gcc/ada/sem_ch12.adb')
-rw-r--r-- | gcc/ada/sem_ch12.adb | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index e80aea5..b5c9e88 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -7574,6 +7574,12 @@ package body Sem_Ch12 is or else not Same_Instantiated_Function (E1, E2)); end if; + -- No check is needed if this is the body of a subprogram that is + -- implicitly created in the case of class-wide predefined functions. + + elsif Ekind (E1) = E_Subprogram_Body then + null; + else raise Program_Error; end if; @@ -14371,8 +14377,21 @@ package body Sem_Ch12 is elsif Scope (Scope (Base_Type (Etype (A_Gen_T)))) = Scope (A_Gen_T) then - Ancestor := - Get_Instance_Of (Base_Type (Etype (A_Gen_T))); + declare + Formal_Ancestor : constant Entity_Id := + Base_Type (Etype (A_Gen_T)); + begin + Ancestor := Get_Instance_Of (Formal_Ancestor); + + -- Handle (rare) case where Get_Instance_Of found nothing in + -- the map. + + if Ancestor = Formal_Ancestor then + Ancestor := + Get_Instance_Of + (Base_Type (Etype (Get_Instance_Of (A_Gen_T)))); + end if; + end; -- The type may be a local derivation, or a type extension of a -- previous formal, or of a formal of a parent package. |