From: Piotr Trojanek <troja...@adacore.com> 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. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/lib-xref-spark_specific.adb | 7 +++++++ 1 file changed, 7 insertions(+) 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; -- 2.43.0