Version 1.3 of ai05s/ai05-0132-1.txt

Unformatted version of ai05s/ai05-0132-1.txt version 1.3
Other versions for file ai05s/ai05-0132-1.txt

!standard 10.1.5(7)          09-03-09 AI05-0132-1/02
!class binding interpretation 09-01-20
!status Amendment 201Z 09-03-09
!status ARG Approved 9-0-0 09-02-21
!status work item 09-01-20
!status received 09-01-12
!priority Low
!difficulty Easy
!qualifier Omission
!subject A library unit pragma must apply to a library unit
!summary
A library unit pragma must apply directly to a library unit, whether or not a name is given.
!question
Consider:
package Pack1 is package Pack2 is pragma Pure; end Pack2;
package Pack3 is pragma Preelaborate; end Pack3; end Pack1;
These are both library unit pragmas. 10.1.5(7) only requires that the name given in a library unit pragma denote a library unit. These pragmas have no name. Moreover, these are "immediately within the visible part declaration of a program unit and before any nested declaration", so it appears that 10.1.5(5/1) is satisfied.
But these pragmas don't apply to a library unit, so something appears to be wrong. Are these pragmas legal? (No.)
!recommendation
(See Summary.)
!wording
Modify 10.1.5(7):
Certain program unit pragmas are defined to be library unit pragmas. {If a library unit pragma applies to a program unit P, P shall be}[The name, if any, in a library unit pragma shall denote the declaration of] a library unit.
!discussion
Clearly, the unit that a library unit pragma applies to should be a library unit. We should just say that.
!corrigendum 10.1.5(7)
Replace the paragraph:
Certain program unit pragmas are defined to be library unit pragmas. The name, if any, in a library unit pragma shall denote the declaration of a library unit.
by:
Certain program unit pragmas are defined to be library unit pragmas. If a library unit pragma applies to a program unit P, P shall be a library unit.
!ACATS Test
ACATS B-Test BA150002 tests a number of these issues but not the exact case mentioned in the question. A new test should be added to check that case.
!appendix

!topic Library unit pragmas in nested packages?
!reference 10.1.5(7)
!from Adam Beneschan 09-01-12
!discussion

In this example:

    package Pack1 is
       package Pack2 is
           pragma Pure;
       end Pack2;

       package Pack3 is
           pragma Preelaborate;
       end Pack3;
    end Pack1;

I think the intent is that the two pragmas are illegal, but I'm not sure the RM says so.
The RM says that Pure and Preelaborate are library unit pragmas.  Library unit pragmas
are a kind of program unit pragma.  10.1.5(5/1) says that one of the places that program
unit pragmas may appear are:

    Immediately within the visible part declaration of a program unit
    and before any nested declaration (but not within a generic formal
    part), in which case the argument, if any, shall be a direct_name
    that denotes the immediately enclosing program unit declaration.

I suppose that "before any nested declaration" could be interpreted in more than one way,
but the language appears to mean "before any nested declaration that is nested within
the program unit referred to by the first part of the sentence", so I don't think this
paragraph makes the pragmas illegal.

10.1.5(7) says, 

    Certain program unit pragmas are defined to be library unit
    pragmas. The name, if any, in a library unit pragma shall denote
    the declaration of a library unit.

If these pragmas had arguments, 10.1.5(5/1) says that the argument would have to be
denote the immediately enclosing program unit declaration, and 10.1.5(7) would then
make that illegal because those names don't denote library units.  But the way
10.1.5(7) is worded, it makes it appear that if there is *no* name, then this
rule doesn't apply (even though the "implied" name, i.e. the immediately enclosing
program unit, would be illegal).

So it's not clear to me that the RM wording makes this illegal.
This looks like an omission to me.

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


Questions? Ask the ACAA Technical Agent