This prevents Freeze_Subprogram_Body from moving the freeze node of a
package body outside of its scope when it contains the instantiation
of a generic subprogram and the parent of the package body happens to
be in the same declarative part as the freeze node of the scope of the
generic subprogram.  This appears to be both unnecessary and counter-
productive in case the package body itself contains a generic unit.

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

gcc/ada/

        * sem_ch12.adb (Freeze_Subprogram_Body): Do not move the freeze
        node of the package body enclosing the instance when its parent
        is in the same declarative part as the freeze node of the parent.
diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb
--- a/gcc/ada/sem_ch12.adb
+++ b/gcc/ada/sem_ch12.adb
@@ -9106,12 +9106,7 @@ package body Sem_Ch12 is
         and then Present (Freeze_Node (Par))
         and then Present (Enc_I)
       then
-         if In_Same_Declarative_Part (Parent (Freeze_Node (Par)), Enc_I)
-           or else
-             (Nkind (Enc_I) = N_Package_Body
-               and then In_Same_Declarative_Part
-                          (Parent (Freeze_Node (Par)), Parent (Enc_I)))
-         then
+         if In_Same_Declarative_Part (Parent (Freeze_Node (Par)), Enc_I) then
             --  The enclosing package may contain several instances. Rather
             --  than computing the earliest point at which to insert its freeze
             --  node, we place it at the end of the declarative part of the


Reply via email to