Ada Conformity Assessment Authority      Home Conformity Assessment   Test Suite ARGAda Standard
Annotated Ada Reference Manual (Ada 2022 Draft 35)Legal Information
Contents   Index   References   Search   Previous   Next 

J.15.1 Pragma Inline


{AI05-0229-1} The form of a pragma Inline, which is a program unit pragma (see 10.1.5), is as follows:
  pragma Inline (name{, name});

Legality Rules

{AI05-0229-1} The pragma shall apply to one or more callable entities or generic subprograms.

Static Semantics

{AI05-0229-1} Pragma Inline specifies that the Inline aspect (see 6.3.2) for each entity denoted by each name given in the pragma has the value True.
Ramification: Note that inline expansion is desired no matter what name is used in the call. This allows one to request inlining for only one of several overloaded subprograms as follows:
package IO is
   procedure Put(X : in Integer);
   procedure Put(X : in String);
   procedure Put(X : in Character);
   procedure Character_Put(X : in Character) renames Put;
   pragma Inline(Character_Put);
end IO;
with IO; use IO;
procedure Main is
   I : Integer;
   C : Character;
   Put(C); -- Inline expansion is desired.
   Put(I); -- Inline expansion is NOT desired.
end Main;

Implementation Permissions

{AI05-0229-1} An implementation may allow a pragma Inline that has an argument which is a direct_name denoting a subprogram_body of the same declarative_part.
Reason: This is allowed for Ada 83 compatibility. This is only a permission as this usage was considered obsolescent even for Ada 95. 
Discussion: We only need to allow this in declarative_parts, because a body is only allowed in another body, and these all have declarative_parts.
NOTE   {AI05-0229-1} {AI12-0440-1} The name in a pragma Inline can may denote more than one entity in the case of overloading. Such a pragma applies to all of the denoted entities. 

Incompatibilities With Ada 83

{AI95-00309-01} {AI05-0229-1} A pragma Inline cannot refer to a subprogram_body outside of that body. The pragma can be given inside of the subprogram body. Ada 2005 adds an Implementation Permission to allow this usage for compatibility (and Ada 95 implementations also can use this permission), but implementations do not have to allow such pragmas.

Extensions to Ada 83

{AI05-0229-1} 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. 

Extensions to Ada 95

{AI95-00309-01} {AI05-0229-1} Amendment Correction: Implementations are allowed to let Pragma Inline apply to a subprogram_body.

Wording Changes from Ada 2005

{AI05-0229-1} {AI05-0299-1} This subclause is new. Pragma Inline was moved here from 6.3.2; aspect Inline lives there now. 

Contents   Index   References   Search   Previous   Next 
Ada-Europe Ada 2005 and 2012 Editions sponsored in part by Ada-Europe