Version 1.1 of ais/ai-00312.txt

Unformatted version of ais/ai-00312.txt version 1.1
Other versions for file ais/ai-00312.txt

!standard 10.1.6 (05)          02-09-26 AI95-00312/00
!standard 4.1.3 (04)
!class binding interpretation 02-09-26
!status work item 02-09-26
!status received 02-09-11
!qualifier Omission
!priority Low
!difficulty Easy
!subject Environment-level visibility rules and generic children
!summary
It is legal to name a generic parent unit in a parent_unit_name, context_clause, and pragma at the place of a compilation unit.
!question
The standard makes the following illegal:
generic package parent is ... end parent;
generic procedure parent.p1; pragma Elaborate_Body (parent.p1); -- illegal
The problem is that "parent.p1" cannot be used to denote the generic procedure. "parent.p1" is not a legal expanded name because "parent" is a generic, not a package, thus 4.1.3(4) does not apply. Moreover, the "enclosing named construct" clause of 4.1.3(4) doesn't apply because the pragma is not enclosed by "parent".
This is surprising. Is this intended to be illegal? (No.)
!recommendation
!wording
!discussion
(* Note: This problem appears to occur in use clauses and pragmas in context clauses, and in grandchildren of generic units as well. It's clear that all of these were intended to be legal. *)
!ACATS test
!appendix

!topic Environment-level visibility rules and generics
!reference RM95 10.1.6(5), 4.1.3(4)
!from Adam Beneschan 09-11-02
!discussion

It appears that the RM makes this illegal, although I'm sure this is
not intentional and appears to be a bug in the RM:

    generic
    package parent is
        ...
    end parent;

    generic
    procedure parent.p1;
    pragma Elaborate_Body (parent.p1);   -- illegal

The problem is that "parent.p1" cannot be used to denote the generic
procedure.  In a non-generic example:

    package parent_2 is
        ...
    end parent;

    procedure parent_2.p2;
    pragma Elaborate_Body (parent_2.p2);

the special visibility rule in 10.1.6(5) states that "parent_2" and
"p2" are both visible; and parent_2 is a valid prefix for an expanded
name, by 4.1.3(4), because it is a package.

However, in the original example, "parent.p1" is not a legal expanded
name because "parent" is a generic, not a package; and the "enclosing
named construct" clause of 4.1.3(4) doesn't apply because the pragma
does not appear to be enclosed by the "parent" construct by any
definition of "enclosing" that I can find.  (8.1 says that the
declarative region of "parent" includes the child unit parent.p1, but
it stops at the semicolon, just before the pragma.)  Thus, "parent.p1"
doesn't meet the definition of an expanded name given by 4.1.3(4) and
is thus illegal.

****************************************************************

Questions? Ask the ACAA Technical Agent