6.3.1 Conformance Rules

From OC Systems Wiki!
Jump to: navigation, search

When subprogram profiles are given in more than one place, they are required to conform in one of four ways: type conformance, mode conformance, subtype conformance, or full conformance.

Static Semantics

As explained in B.1, Interfacing Pragmas, a convention can be specified for an entity. Unless this International Standard states otherwise, the default convention of an entity is Ada. For a callable entity or access-to-subprogram type, the convention is called the calling convention. The following conventions are defined by the language:

  • The default calling convention for any subprogram not listed below is Ada. A pragma Convention, Import, or Export may be used to override the default calling convention (see B.1).
  • The Intrinsic calling convention represents subprograms that are built in to the compiler. The default calling convention is Intrinsic for the following:

  • an enumeration literal;

  • a "/=" operator declared implicitly due to the declaration of "=" (see 6.6);

  • any other implicitly declared subprogram unless it is a dispatching operation of a tagged type;

  • an inherited subprogram of a generic formal tagged type with unknown discriminants;

  • an attribute that is a subprogram;

  • a subprogram declared immediately within a protected_body.

The Access attribute is not allowed for Intrinsic subprograms.
  • The default calling convention is protected for a protected subprogram, and for an access-to-subprogram type with the reserved word protected in its definition.
  • The default calling convention is entry for an entry.
  • If not specified above as Intrinsic, the calling convention for any inherited or overriding dispatching operation of a tagged type is that of the corresponding subprogram of the parent type. The default calling convention for a new dispatching operation of a tagged type is the convention of the type.

Of these four conventions, only Ada and Intrinsic are allowed as a convention_identifier in a pragma Convention, Import, or Export.

Two profiles are type conformant if they have the same number of parameters, and both have a result if either does, and corresponding parameter and result types are the same, or, for access parameters, corresponding designated types are the same.

Two profiles are mode conformant if they are type-conformant, and corresponding parameters have identical modes, and, for access parameters, the designated subtypes statically match.

Two profiles are subtype conformant if they are mode-conformant, corresponding subtypes of the profile statically match, and the associated calling conventions are the same. The profile of a generic formal subprogram is not subtype-conformant with any other profile.

Two profiles are fully conformant if they are subtype-conformant, and corresponding parameters have the same names and have default_expressions that are fully conformant with one another.

Two expressions are fully conformant if, after replacing each use of an operator with the equivalent function_call:

  • each constituent construct of one corresponds to an instance of the same syntactic category in the other, except that an expanded name may correspond to a direct_name (or character_literal) or to a different expanded name in the other; and
  • each direct_name, character_literal, and selector_name that is not part of the prefix of an expanded name in one denotes the same declaration as the corresponding direct_name, character_literal, or selector_name in the other; and
  • each attribute_designator in one must be the same as the corresponding attribute_designator in the other; and
  • each primary that is a literal in one has the same value as the corresponding literal in the other.

Two known_discriminant_parts are fully conformant if they have the same number of discriminants, and discriminants in the same positions have the same names, statically matching subtypes, and default_expressions that are fully conformant with one another.

Two discrete_subtype_definitions are fully conformant if they are both subtype_indications or are both ranges, the subtype_marks (if any) denote the same subtype, and the corresponding simple_expressions of the ranges (if any) fully conform.

Implementation Permissions

An implementation may declare an operator declared in a language-defined library unit to be intrinsic.

Copyright © 1992,1993,1994,1995 Intermetrics, Inc.
Copyright © 2000 The MITRE Corporation, Inc. Ada Reference Manual