According Ada2012 RM Assertion_Policy:
10.2/3 A pragma Assertion_Policy applies to the named assertion aspects in a specific region, and applies to all assertion expressions specified in that region. A pragma Assertion_Policy given in a declarative_part or immediately within a package_specification applies from the place of the pragma to the end of the innermost enclosing declarative region. The region for a pragma Assertion_Policy given as a configuration pragma is the declarative region for the entire compilation unit (or units) to which it applies.
This means that if I have a package hierarchy as per the following example:
└───Root
├───Child1
├───Child2
│ └───GrandSon
└───Child3
And if I define the pragma Assertion_Policy at Root package specification, it will affect to the whole package hierarchy right?
And if I define the pragma Assertion_Policy at Root package specification, it will affect to the whole package hierarchy right?
No.
What your bolded text means is that (a) the pragma is placed immediately in a specification, like so:
Pragme Ada_2012; -- Placed "immediately".
Pragma Assertion_Policy(Check); -- Also "immediately".
Package Some_Spec is --... and so on.
or (b) in a declarative part:
Procedure Outer_Scope is
Pragma Assertion_Polucy( Ignore ); -- Declarative region.
X : Some_Type:= Possibly_Assertion_Failing_Operation;
Package Inner_Scope is
-- the stuff in here would ALSO ignore assertions.
End Inner_Scope;
Package Body Inner_Scope is Separate;
Begin
if X'Valid then
Null; -- Do things on the valid value of X.
end if; -- Because we're ignoring the invalid case.
End Outer_Scope;
So, they apply not to children, but to the spec/body/declarative-region itself.