]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix check for elaboration order on subprogram body stubs
authorPiotr Trojanek <trojanek@adacore.com>
Mon, 16 Jun 2025 14:13:03 +0000 (16:13 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 3 Jul 2025 08:16:29 +0000 (10:16 +0200)
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.

gcc/ada/sem_elab.adb

index 6547813a8e2ec115363bbc8f1550f05d7e4b0511..77b1e120b80077bc53601ca15a9d22fc9e495f20 100644 (file)
@@ -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.