From: Piotr Trojanek Date: Mon, 16 Jun 2025 14:13:03 +0000 (+0200) Subject: ada: Fix check for elaboration order on subprogram body stubs X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=251dab8bc9a596f094149e256f0d216cc5b1a60a;p=thirdparty%2Fgcc.git ada: Fix check for elaboration order on subprogram body stubs Fix an assertion failure occurring when elaboration checks were applied to subprogram with a separate body. gcc/ada/ChangeLog: * sem_elab.adb (Check_Overriding_Primitive): Find early call region of the subprogram body declaration, not of the subprogram body stub. --- diff --git a/gcc/ada/sem_elab.adb b/gcc/ada/sem_elab.adb index 6547813a8e2..77b1e120b80 100644 --- a/gcc/ada/sem_elab.adb +++ b/gcc/ada/sem_elab.adb @@ -15236,7 +15236,15 @@ package body Sem_Elab is end if; Body_Decl := Unit_Declaration_Node (Body_Id); - Region := Find_Early_Call_Region (Body_Decl); + + -- For subprogram bodies in subunits we check where the subprogram + -- body stub is declared. + + if Nkind (Parent (Body_Decl)) = N_Subunit then + Body_Decl := Corresponding_Stub (Parent (Body_Decl)); + end if; + + Region := Find_Early_Call_Region (Body_Decl); -- The freeze node appears prior to the early call region of the -- primitive body.