@@ -856,10 +856,11 @@
-- Start of processing for Analyze_Aspects_At_Freeze_Point
- -- Must be declared in current scope. This is need for a generic
- -- context.
+ -- Must be visible in current scope. Note that this is needed for
+ -- entities that creates their own scope such as protected objects,
+ -- tasks, etc.
- if Scope (E) /= Current_Scope then
+ if not Scope_Within_Or_Same (Current_Scope, Scope (E)) then
@@ -2434,11 +2435,12 @@
-- Must be declared in current scope or in case of an aspect
- -- specification, must be the current scope.
+ -- specification, must be visible in current scope.
elsif Scope (Ent) /= Current_Scope
- and then (not From_Aspect_Specification (N)
- or else Ent /= Current_Scope)
+ and then
+ not (From_Aspect_Specification (N)
+ and then Scope_Within_Or_Same (Current_Scope, Scope (Ent)))
Error_Msg_N ("entity must be declared in this scope", Nam);