CVS difference for ais/ai-00309.txt
--- ais/ai-00309.txt 2002/10/01 03:08:54 1.1
+++ ais/ai-00309.txt 2004/04/27 03:37:52 1.2
@@ -1,8 +1,10 @@
-!standard 6.3.2 (03) 02-09-25 AI95-00309/00
+!standard 6.3.2 (06) 04-04-26 AI95-00309/01
+!standard 6.3.2 (03)
!standard 10.1.5 (02)
!standard 10.1.5 (05)
!standard 10.1.5 (06)
!class binding interpretation 02-09-25
+!status work item 04-04-26
!status received 02-09-17
@@ -11,6 +13,8 @@
+Pragma Inline may refer to a subprogram_body without a subprogram_declaration.
It seems that the standard makes a case illegal that was legal in Ada 83;
@@ -31,85 +35,42 @@
pragma Inline (Proc1); -- legal in Ada83, illegal in Ada95
-RM83 6.3.2(3) says about Pragma Inline: "If the pragma appears at the
-place of a declarative item, each name must denote a subpropgram or a
-generic subprogram declared by an earlier declarative item of the same
-declarative part or package specification". A "declarative item", as
-defined in RM83 3.9(1-2), can be either a basic_declarative_item or a
-later_declarative_item, and a subprogram body is a type of
-later_declarative_item, so the pragma is legal. AI83-00242 seems to
-support the legality of this pragma placement; one of the examples in
-this AI contains a nested subprogram body and a Pragma Inline that
-follows the body.
-In RM95, though, 6.3.2 says that Pragma Inline is a program unit
-pragma, and 10.1.5(6) says that pragmas that occur "at a place of a
-declaration other than the first" shall have an argument that denotes
-a subprogram_declaration, generic_subprogram_declaration, or
-generic_instantiation. A subprogram body is not, syntactically, a
-subprogram_declaration. 6.3 makes it clear that a subprogram body
-that is not the completion of a subprogram_declaration does constitute
-the initial declaration of the subprogram; however, the font used in
-10.1.5(6) and the underscore in "subprogram_declaration" appear to
-make it clear that the pragma must refer to an actual
-subprogram_declaration that appears in the source and not just
-anything that constitutes a subprogram declaration.
-So it appears that the above example is legal in Ada 83 but not in Ada
-(2) In AARM95 6.3.2, under "Extensions to Ada 83" in AARM95, is the
- A pragma Inline is allowed inside a subprogram_body if there is no
- corresponding subprogram_declaration. This is for uniformity with
- other program unit pragmas.
-This seems to imply that the Inline pragma would *not* be allowed
-inside a subprogram body if there *is* a corresponding
-subprogram_declaration. However, I cannot find anything in 10.1.5
-that disallows this. 10.1.5(2) says
- A name given as the argument of a program unit program
-(*) shall resolve to denote the declarations or renamings of one or
- more program units that occur immediately within the declarative
- region or compilation in which the pragma immediately occurs, or
-(**) it shall resolve to denote the declaration of the immediately
- enclosing program unit (if any);
+RM83 6.3.2(3) allows Inline at the place of any declarative item.
+For Ada 95, however, the standard says the pragma is a program unit pragma,
+which must denote a subprogram_declaration, which is not a subprogram_body. Was
+this incompatibility intentional? (No.)
-In this case:
- package Pak1 is
- procedure Proc2;
- end Pak1;
- package body Pak1 is
- procedure Proc2 is
- pragma Inline (Proc2); -- legal?
- end Proc2;
- end Pak1;
+Add an implementation permission after 6.3.2(6):
-the pragma doesn't satisfy the clause (*), but it does appear to
-satisfy (**); and it certainly satisfies 10.1.5(5).
+An implementation may allow a pragma Inline at the place of a declaration other
+than the first, of a declarative_part, which has an argument which is a
+direct_name that denotes subprogram_body of the same declarative_part.
+AARM Note: We only need to allow this in declarate_parts, because a body
+is only allowed in another body, and these all have declarative_parts.
+[Do we need to say something to allow other items (such as a
+subprogram_declaration) in this pragma.
-So what is the real rule? Is an Inline pragma that denotes a
-subprogram P allowed in the body of P (as the first declarative item)
-if there was an earlier subprogram_declaration for P?
+The incompatibility does not appear to have been intentional, as it was
+not listed in the AARM as an incompatibility.
+We add an implementation permission for pragma Inline only, because changing
+the definition of program unit pragmas would affect many other pragmas.
+Moreover, this use can be considered obsolscent, as Ada 95 allows the pragma
+to be given within the body to have the same effect.
+This is a permission, so no test is needed.
Questions? Ask the ACAA Technical Agent