3.11.1 Completions of Declarations
1/3
1.a
Discussion:
Throughout the RM95, there are rules about completions that define
the following:
1.b
Which declarations require a corresponding
completion.
1.c
Which constructs can only serve as the completion
of a declaration.
1.d
Where the completion of a declaration is allowed
to be.
1.e
What kinds of completions are allowed to correspond
to each kind of declaration that allows one.
1.f
Don't confuse this compile-time concept with
the run-time concept of completion defined in
7.6.1.
1.g
Note that the declaration of a private type
(if limited) can be completed with the declaration of a task type, which
is then completed with a body. Thus, a declaration can actually come
in three parts.
1.h/3
{
AI95-00217-06}
{
AI05-0162-1}
An incomplete type
(whether declared in the limited view of a package or not) may be completed
by a private type declaration In
Ada 2005 the limited view of the package contains an incomplete view
of the private type, so we can in
fact have four parts now.
1.i/3
{
AI05-0229-1}
In Ada 2012, there are no language-defined pragmas
that act as completions. Pragma Import (which is obsolescent) has the
effect of setting aspect Import to True; such an aspect makes giving
a completion illegal. We considered removing the wording which allows
pragmas as completions, but decided to leave it for the benefit for implementation-defined
pragmas which may want to act as a completion.
Name Resolution Rules
2
A construct that can
be a completion is interpreted as the completion of a prior declaration
only if:
3
The declaration and the completion occur immediately
within the same declarative region;
4
5
If the declaration is overloadable, then the completion
either has a type-conformant profile, or is a
pragma.
Legality Rules
6/3
{
AI05-0229-1}
An implicit declaration shall not have a completion.
For
any explicit declaration that is specified to
require completion,
there shall be a corresponding explicit completion
,
unless the declared entity is imported (see B.1).
6.a.1/2
To be honest: {
AI95-00217-06}
The implicit declarations occurring in a limited
view do have a completion (the explicit declaration occurring in the
full view) but that's a special case, since the implicit declarations
are actually built from the explicit ones. So they do not require
a completion, they have one by fiat.
6.a
Discussion: The implicit declarations
of predefined operators are not allowed to have a completion. Enumeration
literals, although they are subprograms, are not allowed to have a corresponding
subprogram_body.
That's because the completion rules are described in terms of constructs
(
subprogram_declarations)
and not entities (subprograms). When a completion is required, it has
to be explicit; the implicit null
package_body
that Section 7 talks about cannot serve as the completion of a
package_declaration
if a completion is required.
7
At most one completion is allowed for a given declaration.
Additional requirements on completions appear where each kind of completion
is defined.
7.a
Ramification: A subunit is not a completion;
the stub is.
7.b
If the completion of a declaration is also a
declaration, then that declaration might have a completion, too.
For example, a limited private type can be completed with a task type,
which can then be completed with a task body. This is not a violation
of the “at most one completion” rule.
8
A type is
completely defined
at a place that is after its full type definition (if it has one) and
after all of its subcomponent types are completely defined. A type shall
be completely defined before it is frozen (see
13.14
and
7.3).
8.a
Reason: Index types are always completely
defined — no need to mention them. There is no way for a completely
defined type to depend on the value of a (still) deferred constant.
9/3
96 {
AI05-0229-1}
Completions are in principle allowed for any kind of explicit declaration.
However, for some kinds of declaration, the only allowed completion is
an implementation-defined pragma a
pragma Import,
and implementations are not required to
have any
such pragmas support pragma
Import for every kind of entity.
9.a/3
This paragraph
was deleted.Discussion: {
AI05-0229-1}
In fact, we expect that implementations will not
support pragma Import of things like types — it's hard to even
define the semantics of what it would mean. Therefore, in practice, not
every explicit declaration can have a completion. In any case, if an
implementation chooses to support pragma Import for, say, types, it can
place whatever restrictions on the feature it wants to. For example,
it might want the pragma
to be a freezing point for the type.
10
97 There are rules that prevent premature
uses of declarations that have a corresponding completion. The Elaboration_Checks
of
3.11 prevent such uses at run time for
subprograms, protected operations, tasks, and generic units. The rules
of
13.14, “
Freezing
Rules” prevent, at compile time, premature uses of other entities
such as private types and deferred constants.
Wording Changes from Ada 83
10.a
This subclause is new. It is intended to cover
all kinds of completions of declarations, be they a body for a spec,
a full type for an incomplete or private type, a full constant declaration
for a deferred constant declaration, or a
pragma
Import for any kind of entity.
Wording Changes from Ada 95
10.b/2
Wording Changes from Ada 2005
10.c/3
{
AI95-0177-1}
Added null procedures and expression functions
that are completions to the definition of body.
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe