4.9.1 Statically Matching Constraints and Subtypes
Static Semantics
A constraint
statically matches
another constraint if:
both are null constraints;
both are static and have equal corresponding bounds
or discriminant values;
A subtype
statically matches
another subtype of the same type if they have statically matching constraints,
all predicate specifications that apply to them come from the same declarations,
and, for access subtypes, either both or neither exclude null. Two anonymous
access-to-object subtypes statically match if their designated subtypes
statically match, and either both or neither exclude null, and either
both or neither are access-to-constant. Two anonymous access-to-subprogram
subtypes statically match if their designated profiles are subtype conformant,
and either both or neither exclude null.
Two ranges of the same type
statically
match if both result from the same evaluation of a
range,
or if both are static and have equal corresponding bounds.
A constraint is
statically
compatible with a scalar subtype if it statically matches the constraint
of the subtype, or if both are static and the constraint is compatible
with the subtype.
A constraint is
statically compatible
with an access or composite subtype if it statically matches the constraint
of the subtype, or if the subtype is unconstrained.
Two
statically matching subtypes are statically compatible with each other.
In addition, a subtype
S1 is statically compatible with a subtype
S2 if:
the constraint of S1 is statically compatible
with S2, and
if S2 excludes null, so does S1,
and
either:
all predicate specifications that
apply to S2 apply also to S1, or
both subtypes are static, every
value that satisfies the predicates of
S1 also satisfies the predicates
of
S2, and it is not the case that both types each have at least
one applicable predicate specification, predicate checks are enabled
(see
11.4.2) for
S2, and predicate
checks are not enabled for
S1.
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe