From: Piotr Trojanek Date: Wed, 28 May 2025 13:42:10 +0000 (+0200) Subject: ada: Fix SPARK context discovery from within subunits X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0fb0140c2ec957b10f550a70a616e3205927b1b5;p=thirdparty%2Fgcc.git ada: Fix SPARK context discovery from within subunits When navigating the AST to find the enclosing subprogram we must traverse from subunits to the corresponding stub. gcc/ada/ChangeLog: * lib-xref-spark_specific.adb (Enclosing_Subprogram_Or_Library_Package): Traverse subunits and body stubs. --- diff --git a/gcc/ada/lib-xref-spark_specific.adb b/gcc/ada/lib-xref-spark_specific.adb index d77d6aa4dd0..03693a96bae 100644 --- a/gcc/ada/lib-xref-spark_specific.adb +++ b/gcc/ada/lib-xref-spark_specific.adb @@ -258,6 +258,13 @@ package body SPARK_Specific is Context := Defining_Entity (Context); exit; + when N_Subunit => + Context := Corresponding_Stub (Context); + + when N_Body_Stub => + Context := Corresponding_Spec_Of_Stub (Context); + exit; + when others => Context := Parent (Context); end case;