Ada Conformity Assessment Authority |
Home |
Conformity Assessment | Test Suite |
ARG | Ada Standard |

A record type with a variant_part
specifies alternative lists of components. Each variant
defines the components for the value or values of the discriminant covered
by its discrete_choice_list.

The *discriminant_*direct_name
shall resolve to denote a discriminant (called the *discriminant of
the **variant_part*)
specified in the known_discriminant_part
of the full_type_declaration
that contains the variant_part.
The expected type for each discrete_choice
in a variant
is the type of the discriminant of the variant_part.

The discriminant of the variant_part
shall be of a discrete type.

The choice_expressions,
subtype_indications,
and ranges
given as discrete_choices
in a variant_part
shall be static. The discrete_choice
**others** shall appear alone in a discrete_choice_list,
and such a discrete_choice_list,
if it appears, shall be the last one in the enclosing construct.

A discrete_choice
that is a choice_expression
covers a value if the value equals the value of the choice_expression
converted to the expected type.

A discrete_choice
that is a subtype_indication
covers all values (possibly none) that belong to the subtype and that
satisfy the static predicates of the subtype (see 3.2.4).

A discrete_choice
that is a range
covers all values (possibly none) that belong to the range.

The discrete_choice
**others** covers all values of its expected type that are not covered
by previous discrete_choice_lists
of the same construct.

The possible values
of the discriminant of a variant_part
shall be covered as follows:

If the discriminant is of a static constrained
scalar subtype then, except within an instance of a generic unit, each
non-**others** discrete_choice
shall cover only values in that subtype that satisfy its predicates,
and each value of that subtype that satisfies its predicates shall be
covered by some discrete_choice
(either explicitly or by **others**);

If the type of the discriminant is a descendant
of a generic formal scalar type, then the variant_part
shall have an **others** discrete_choice;

Otherwise, each value of the base range of the
type of the discriminant shall be covered (either explicitly or by **others**).

Two distinct discrete_choices
of a variant_part
shall not cover the same value.

The discriminant
of a variant_part
is said to *govern* the variant_part
and its variants.
In addition, the discriminant of a derived type governs a variant_part
and its variants
if it corresponds (see 3.7) to the discriminant
of the variant_part.

A record value contains the values of the components
of a particular variant
only if the value of the discriminant governing the variant
is covered by the discrete_choice_list
of the variant.
This rule applies in turn to any further variant
that is, itself, included in the component_list
of the given variant.

When an object of a discriminated type *T*
is initialized by default, Constraint_Error is raised if no discrete_choice_list
of any variant
of a variant_part
of *T* covers the value of the discriminant that governs the variant_part.
When a variant_part
appears in the component_list
of another variant
*V*, this test is only applied if the value of the discriminant
governing *V* is covered by the discrete_choice_list
of *V*.

The elaboration of a variant_part
consists of the elaboration of the component_list
of each variant
in the order in which they appear.

Status : State;

Line_Count : Integer

Cylinder : Cylinder_Index;

Track : Track_Number;

Writer : Peripheral(Unit => Printer);

Archive : Disk_Unit;

Archive : Disk_Unit;

Ada 2005 and 2012 Editions sponsored in part by **Ada-Europe**