This commit fixes an issue where when creating initialization
procedures, GNAT would generate failing accessibility checks because it
would use the scope depth of the parameter of the initialization
procedure instead of using the scope depth passed as parameter.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

        * sem_util.adb (Accessibility_Level): Use init_proc_level_formal
        instead of computing a new accessibility level from Scope_Depth
        (E).
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -744,6 +744,13 @@ package body Sem_Util is
             then
                return Accessibility_Level (Related_Expression (E));
 
+            elsif Level = Dynamic_Level
+               and then Ekind (E) in E_In_Parameter | E_In_Out_Parameter
+               and then Present (Init_Proc_Level_Formal (Scope (E)))
+            then
+               return New_Occurrence_Of
+                        (Init_Proc_Level_Formal (Scope (E)), Loc);
+
             --  Normal object - get the level of the enclosing scope
 
             else


Reply via email to