===================================================================
@@ -564,8 +564,12 @@
-- Freeze_xxx mechanism because it must also work in the context of
-- generics where normal freezing is disabled.
- Analyze_Enclosing_Package_Body_Contract (N);
+ -- Only bodies coming from source should cause this type of "freezing"
+ if Comes_From_Source (N) then
+ Analyze_Enclosing_Package_Body_Contract (N);
+ end if;
+
-- Find corresponding package specification, and establish the current
-- scope. The visible defining entity for the package is the defining
-- occurrence in the spec. On exit from the package body, all body
===================================================================
@@ -3011,8 +3011,15 @@
-- decoupled from the usual Freeze_xxx mechanism because it must also
-- work in the context of generics where normal freezing is disabled.
- Analyze_Enclosing_Package_Body_Contract (N);
+ -- Only bodies coming from source should cause this type of "freezing".
+ -- Expression functions that act as bodies and complete an initial
+ -- declaration must be included in this category, hence the use of
+ -- Original_Node.
+ if Comes_From_Source (Original_Node (N)) then
+ Analyze_Enclosing_Package_Body_Contract (N);
+ end if;
+
-- Generic subprograms are handled separately. They always have a
-- generic specification. Determine whether current scope has a
-- previous declaration.