https://gcc.gnu.org/g:251dab8bc9a596f094149e256f0d216cc5b1a60a
commit r16-1955-g251dab8bc9a596f094149e256f0d216cc5b1a60a Author: Piotr Trojanek <troja...@adacore.com> Date: Mon Jun 16 16:13:03 2025 +0200 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: --- gcc/ada/sem_elab.adb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gcc/ada/sem_elab.adb b/gcc/ada/sem_elab.adb index 6547813a8e2e..77b1e120b800 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.