===================================================================
@@ -2649,9 +2649,27 @@
-- in order to perform visibility checks on delayed aspects.
Adjust_Decl;
- Freeze_All (First_Entity (Current_Scope), Decl);
- Freeze_From := Last_Entity (Current_Scope);
+ -- If the current scope is a generic subprogram body. skip
+ -- the generic formal parameters that are not frozen here.
+
+ if Is_Subprogram (Current_Scope)
+ and then Nkind (Unit_Declaration_Node (Current_Scope))
+ = N_Generic_Subprogram_Declaration
+ and then Present (First_Entity (Current_Scope))
+ then
+ while Is_Generic_Formal (Freeze_From) loop
+ Freeze_From := Next_Entity (Freeze_From);
+ end loop;
+
+ Freeze_All (Freeze_From, Decl);
+ Freeze_From := Last_Entity (Current_Scope);
+
+ else
+ Freeze_All (First_Entity (Current_Scope), Decl);
+ Freeze_From := Last_Entity (Current_Scope);
+ end if;
+
-- Current scope is a package specification
elsif Scope (Current_Scope) /= Standard_Standard
===================================================================
@@ -1053,9 +1053,13 @@
return
Nkind_In (Kind, N_Formal_Object_Declaration,
- N_Formal_Package_Declaration,
N_Formal_Type_Declaration)
- or else Is_Formal_Subprogram (E);
+ or else Is_Formal_Subprogram (E)
+
+ or else
+ (Ekind (E) = E_Package
+ and then Nkind (Original_Node (Unit_Declaration_Node (E))) =
+ N_Formal_Package_Declaration);
end if;
end Is_Generic_Formal;