return;
end if;
- -- Handle front-end inlining
+ -- Handle inlining
-- Note: Normally we don't do any inlining if expansion is off, since
-- we won't generate code in any case. An exception arises in GNATprove
if not Back_End_Inlining then
if (Has_Pragma_Inline_Always (Spec_Id)
- and then not Opt.Disable_FE_Inline_Always)
- or else
- (Has_Pragma_Inline (Spec_Id) and then Front_End_Inlining
- and then not Opt.Disable_FE_Inline)
+ and then not Opt.Disable_FE_Inline_Always)
+ or else (Front_End_Inlining
+ and then not Opt.Disable_FE_Inline)
then
Build_Body_To_Inline (N, Spec_Id);
end if;
- -- New implementation (relying on backend inlining)
+ -- New implementation (relying on back-end inlining)
else
if Has_Pragma_Inline_Always (Spec_Id)
-- Enabled: inlining is requested/required for the subprogram
procedure Process_Inline (Status : Inline_Status);
- -- Common processing for Inline, Inline_Always and No_Inline. Parameter
+ -- Common processing for No_Inline, Inline and Inline_Always. Parameter
-- indicates the inline status specified by the pragma.
procedure Process_Interface_Name
-- processing the arguments of the pragma.
procedure Make_Inline (Subp : Entity_Id);
- -- Subp is the defining unit name of the subprogram declaration. Set
- -- the flag, as well as the flag in the corresponding body, if there
- -- is one present.
+ -- Subp is the defining unit name of the subprogram declaration. If
+ -- the pragma is valid, call Set_Inline_Flags on Subp, as well as on
+ -- the corresponding body, if there is one present.
procedure Set_Inline_Flags (Subp : Entity_Id);
- -- Sets Is_Inlined and Has_Pragma_Inline flags for Subp and also
- -- Has_Pragma_Inline_Always for the Inline_Always case.
+ -- Set Has_Pragma_{No_Inline,Inline,Inline_Always} flag on Subp.
+ -- Also set or clear Is_Inlined flag on Subp depending on Status.
function Inlining_Not_Possible (Subp : Entity_Id) return Boolean;
-- Returns True if it can be determined at this stage that inlining
-- is not possible, for example if the body is available and contains
-- exception handlers, we prevent inlining, since otherwise we can
-- get undefined symbols at link time. This function also emits a
- -- warning if front-end inlining is enabled and the pragma appears
- -- too late.
+ -- warning if the pragma appears too late.
--
-- ??? is business with link symbols still valid, or does it relate
-- to front end ZCX which is being phased out ???
elsif Nkind (Decl) = N_Subprogram_Declaration
and then Present (Corresponding_Body (Decl))
then
- if Front_End_Inlining
- and then Analyzed (Corresponding_Body (Decl))
- then
+ if Analyzed (Corresponding_Body (Decl)) then
Error_Msg_N ("pragma appears too late, ignored??", N);
return True;
-- If inlining is not possible, for now do not treat as an error
elsif Status /= Suppressed
+ and then Front_End_Inlining
and then Inlining_Not_Possible (Subp)
then
Applies := True;
end if;
end if;
- if not Has_Pragma_Inline (Subp) then
- Set_Has_Pragma_Inline (Subp);
- end if;
+ Set_Has_Pragma_Inline (Subp);
end if;
-- Then adjust the Is_Inlined flag. It can never be set if the
if not GNATprove_Mode then
- -- Inline status is Enabled if inlining option is active
+ -- Inline status is Enabled if option -gnatn is specified.
+ -- However this status determines only the value of the
+ -- Is_Inlined flag on the subprogram and does not prevent
+ -- the pragma itself from being recorded for later use,
+ -- in particular for a later modification of Is_Inlined
+ -- independently of the -gnatn option.
+
+ -- In other words, if -gnatn is specified for a unit, then
+ -- all Inline pragmas processed for the compilation of this
+ -- unit, including those in the spec of other units, are
+ -- activated, so subprograms will be inlined across units.
+
+ -- If -gnatn is not specified, no Inline pragma is activated
+ -- here, which means that subprograms will not be inlined
+ -- across units. The Is_Inlined flag will nevertheless be
+ -- set later when bodies are analyzed, so subprograms will
+ -- be inlined within the unit.
if Inline_Active then
Process_Inline (Enabled);