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

Certain expressions of a scalar or string type are
defined to be static. Similarly, certain discrete ranges are defined
to be static, and certain scalar and string subtypes are defined to be
static subtypes. *Static* means determinable
at compile time, using the declared properties or values of the program
entities.

a numeric_literal
of a numeric type;

a string_literal
of a static string subtype;

a name
that denotes the declaration of a static constant;

a name
that denotes a named number, and that is interpreted as a value of a
numeric type;

a function_call
whose *function_*name
or *function_*prefix
statically denotes a static function, and whose actual parameters, if
any (whether given explicitly or by default), are all static expressions;

an attribute_reference
that denotes a scalar value, and whose prefix
denotes a static scalar subtype;

an attribute_reference
whose prefix
statically names a statically constrained array object or array subtype,
and whose attribute_designator
is First, Last, or Length, with an optional dimension;

an attribute_reference
whose prefix
denotes a non-generic entity that is not declared in a generic unit,
and whose attribute_designator
is Nonblocking;

a type_conversion
whose subtype_mark
denotes a static (scalar or string) subtype, and whose operand is a static
expression;

a qualified_expression
whose subtype_mark
denotes a static (scalar or string) subtype, and whose operand is a static
expression;

a membership test whose *tested_*simple_expression
is a static expression, and whose membership_choice_list
consists only of membership_choices
that are either static *choice_*simple_expressions,
static ranges,
or subtype_marks
that denote a static (scalar or string) subtype;

a short-circuit control form both of whose relations
are static expressions;

a conditional_expression
all of whose conditions,
*selecting_*expressions,
and *dependent_*expressions
are static expressions;

a declare_expression
whose *body_*expression
is static and each of whose declarations, if any, is either the declaration
of a static constant or is an object_renaming_declaration
with an *object_*name
that statically names the renamed object;

a static expression enclosed in parentheses.

It is a direct_name,
expanded name, or character_literal,
and it denotes a declaration other than a renaming_declaration;
or

It is an attribute_reference
whose prefix
statically denotes some entity; or

It is a target_name
(see 5.2.1) in an assignment_statement
whose *variable_*name
statically denotes some entity; or

It denotes a renaming_declaration
with a name
that statically denotes the renamed entity.

statically denotes the declaration of an object
(possibly through one or more renames);

is a selected_component
whose prefix statically names an object, there is no implicit dereference
of the prefix, and the selector_name
does not denote a component_declaration
occurring within a variant_part;
or

is an indexed_component
whose prefix statically names an object, there is no implicit dereference
of the prefix, the object is statically constrained, and the index expressions
of the object are static and have values that are within the range of
the index constraint.

For an entity other than an object, a name
statically names an entity if the name
statically denotes the entity.

a predefined operator whose parameter and result
types are all scalar types none of which are descendants of formal scalar
types;

a predefined relational operator whose parameters
are of a string type that is not a descendant of a formal array type;

a predefined concatenation operator whose result
type is a string type that is not a descendant of a formal array type;

a shifting or rotating function associated with
a modular type declared in package Interfaces (see B.2);

an enumeration literal;

a static expression function (see 6.8);

a language-defined attribute that is a function,
if the prefix
denotes a static scalar subtype, and if the parameter and result types
are scalar.

In any case, a generic formal subprogram is not a
static function.

A *static constant* is a
constant view declared by a full constant declaration or an object_renaming_declaration
with a static nominal subtype, having a value defined by a static scalar
expression or by a static string expression, and which satisfies any
constraint or predicate that applies to the nominal subtype.

A *static range* is a range
whose bounds are static expressions, or a range_attribute_reference
that is equivalent to such a range.
A *static **discrete_range*
is one that is a static range or is a subtype_indication
that defines a static scalar subtype. The base range of a scalar type
is a static range, unless the type is a descendant of a formal scalar
type.

A *static subtype* is either
a *static scalar subtype* or a *static string subtype*. A
static scalar subtype is an unconstrained scalar subtype whose type is
not a descendant of a formal type, or a constrained scalar subtype formed
by imposing a compatible static constraint on a static scalar subtype.
A static string subtype is an unconstrained string
subtype whose index subtype and component subtype are static, or a constrained
string subtype formed by imposing a compatible static constraint on a
static string subtype. In any case, the subtype of a generic formal object
of mode **in out**, and the result subtype of a generic formal function,
are not static. Also, a subtype is not static if any Dynamic_Predicate
specifications apply to it.

A null constraint is always static;

An index constraint is static
if each discrete_range
is static, and each index subtype of the corresponding array type is
static;

A discriminant constraint is
static if each expression
of the constraint is static, and the subtype of each discriminant is
static.

In any case, the constraint of the first subtype
of a scalar formal type is neither static nor null.

A subtype is *statically constrained*
if it is constrained, and its constraint is static. An object is *statically
constrained* if its nominal subtype is statically constrained, or
if it is a static string constant.

the right operand of a static short-circuit control
form whose value is determined by its left operand; or

a *dependent_*expression
of an if_expression
whose associated condition
is static and equals False; or

a condition
or *dependent_*expression
of an if_expression
where the condition
corresponding to at least one preceding *dependent_*expression
of the if_expression
is static and equals True; or

a *dependent_*expression
of a case_expression
whose *selecting_*expression
is static and whose value is not covered by the corresponding discrete_choice_list;
or

a *choice_*simple_expression
(or a simple_expression
of a range
that occurs as a membership_choice
of a membership_choice_list)
of a static membership test that is preceded in the enclosing membership_choice_list
by another item whose individual membership test (see 4.5.2)
statically yields True.

A static expression
is evaluated at compile time except when it is statically unevaluated.
The compile-time evaluation of a static expression is performed exactly,
without performing Overflow_Checks. For a static expression that is evaluated:

The expression is illegal if its evaluation fails
a language-defined check other than Overflow_Check. For the purposes
of this evaluation, the assertion policy is assumed to be Check.

If the expression is not part of a larger static
expression and the expression is expected to be of a single specific
type, then its value shall be within the base range of its expected type.
Otherwise, the value may be arbitrarily large or small.

If the expression is of type *universal_real*
and its expected type is a decimal fixed point type, then its value shall
be a multiple of the *small* of the decimal type. This restriction
does not apply if the expected type is a descendant of a formal scalar
type (or a corresponding actual type in an instance).

In addition to the places where
Legality Rules normally apply (see 12.3),
the above restrictions also apply in the private part of an instance
of a generic unit.

For a real static expression that is not part of
a larger static expression, and whose expected type is not a descendant
of a formal type, the implementation shall round or truncate the value
(according to the Machine_Rounds attribute of the expected type) to the
nearest machine number of the expected type; if the value is exactly
half-way between two machine numbers, the rounding performed is implementation-defined.
If the expected type is a descendant of a formal type, or if the static
expression appears in the body of an instance of a generic unit and the
corresponding expression is nonstatic in the corresponding generic body,
then no special rounding or truncating is required — normal accuracy
rules apply (see Annex G).

For a real static expression that is not part of
a larger static expression, and whose expected type is not a descendant
of a formal type, the rounding should be the same as the default rounding
for the target system.

NOTES

29 An expression can be static even if
it occurs in a context where staticness is not required.

30 A static (or run-time) type_conversion
from a real type to an integer type performs rounding. If the operand
value is exactly half-way between two integers, the rounding is performed
away from zero.

1 + 1 *-- 2*

**abs**(-10)*3 *-- 30*

Kilo : **constant** := 1000;

Mega :**constant** := Kilo*Kilo; *-- 1_000_000*

Long :**constant** := Float'Digits*2;

Mega :

Long :

Half_Pi : **constant** := Pi/2; *-- see 3.3.2*

Deg_To_Rad :**constant** := Half_Pi/90;

Rad_To_Deg :**constant** := 1.0/Deg_To_Rad; *-- equivalent to 1.0/((3.14159_26536/2)/90)*

Deg_To_Rad :

Rad_To_Deg :

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