Version 1.2 of ai05s/ai05-0063-1.txt

Unformatted version of ai05s/ai05-0063-1.txt version 1.2
Other versions for file ai05s/ai05-0063-1.txt

!standard 3.7(10/2)          08-02-01 AI05-0063-1/02
!class binding interpretation 07-09-06
!status work item 07-09-06
!status received 07-09-06
!priority Low
!difficulty Easy
!qualifier Error
!subject Access discriminants on derived formal types
Formal non-tagged limited types are not inherently limited. A type derived from such a formal type in a generic unit cannot have access discriminants with defaults.
ACATS 3.0 test B370001 has the following example (note that this test is a revision of an Ada 95 ACATS test):
generic type FP (DD: access Disc) is limited private; package GenLP is type DFP (D: access Disc := A_Disc) is new FP(D); -- Checked in instance. end GenLP;
package Instance_Tsk is new GenLP (Tsk); -- OK. package Instance_PT is new GenLP (PT); -- OK. package Instance_LimRec is new GenLP (LimRec); -- OK. package Instance_NonLimRec is new GenLP (NonLimRec); -- ERROR:
The test writer thought that this derived type would be legal here and rechecked in the instance.
However, the actual wording of the rule 3.7(10/2) allows default expressions only on descendants of task, protected, or explicitly limited record types. FP is none of these things (an explicitly limited record type needs to be declared by a record_type_definition).
What is the intent here?
The declaration of a type derived from an untagged limited formal type cannot have defaulted discriminants.
[No wording is needed here; AI05-0059-1 includes the needed wording change to make 3.7(10/2) depend on the definition of "inherently limited".]
AARM note after definition of "inherently limited" after 7.5 (6): A limited formal type is not inherently limited if it is not explicitly tagged.
The current rule works well for generic bodies, where it easily provides an assume-the-worst rule. But this case seems to need an assume-the-best rule for generic specifications. Otherwise, it would not be possible to give a default for an access discriminant given in a generic specification.
[Editor's note: One has to wonder whether this is important enough to bother with fixing. A default is mainly useful to allow changing of the discriminant (in a mutable type), and that is of course not possible for limited types anyway. Surely the easiest fix is to confirm the wording -- thus I didn't propose a wording fix here.
OTOH, it seems like a bit of wart. It is unusual that we assume-the-worst everywhere in a generic and provide no way to do this rather than allowing movement to the specification.]
***************************** If default discriminants are needed, it is always possible to make the formal explicitly tagged, or to use a derived type whose ancestor is inherently limited so this is a very mild restriction that is simpler to describe that the "legal in spec/assume the worst in body" formulation.. [Editor's note: If the formal is explicitly tagged, then defaults are not allowed by 3.7(9.1/2) -- tagged types can never have discriminant defaults. This is only talking about untagged types.] *****************************
--!corrigendum 7.4(6/2)
Replace this case in the ACATS B-Test B370001.


Questions? Ask the ACAA Technical Agent