if Is_Generic_Instance (Pack) then
null;
+ -- Do not inline the package if the subprogram is an init proc
+ -- or other internally generated subprogram, because in that
+ -- case the subprogram body appears in the same unit that
+ -- declares the type, and that body is visible to the back end.
+
elsif not Is_Inlined (Pack)
- and then
- (not Has_Completion (E)
- or else Is_Expression_Function (E))
+ and then Comes_From_Source (E)
then
Set_Is_Inlined (Pack);
Inlined_Bodies.Increment_Last;
-- Start of processing for Add_Inlined_Subprogram
begin
- -- Insert the current subprogram in the list of inlined subprograms, if
- -- it can actually be inlined by the back-end, and if its unit is known
- -- to be inlined, or is an instance whose body will be analyzed anyway.
-
- if (Is_Inlined (Pack) or else Is_Generic_Instance (Pack))
+ -- If the subprogram is to be inlined, and if its unit is known to be
+ -- inlined or is an instance whose body will be analyzed anyway or the
+ -- subprogram has been generated by the compiler, and if it is declared
+ -- at the library level not in the main unit, and if it can be inlined
+ -- by the back-end, then insert it in the list of inlined subprograms.
+
+ if Is_Inlined (E)
+ and then (Is_Inlined (Pack)
+ or else Is_Generic_Instance (Pack)
+ or else Is_Internal (E))
and then not Scope_In_Main_Unit (E)
- and then Is_Inlined (E)
and then not Is_Nested (E)
and then not Has_Initialized_Type (E)
then
return;
end if;
- -- If the instance appears within a generic subprogram there is nothing
- -- to finalize either.
+ -- If the instance is within a generic unit, no finalization code
+ -- can be generated. Note that at this point all bodies have been
+ -- analyzed, and the scope stack itself is not present, and the flag
+ -- Inside_A_Generic is not set.
declare
S : Entity_Id;
begin
S := Scope (Inst);
while Present (S) and then S /= Standard_Standard loop
- if Is_Generic_Subprogram (S) then
+ if Is_Generic_Unit (S) then
return;
end if;
Set_Uses_Sec_Stack
(Protected_Body_Subprogram (Scop),
Uses_Sec_Stack (Scop));
- Set_Finalization_Chain_Entity
- (Protected_Body_Subprogram (Scop),
- Finalization_Chain_Entity (Scop));
+
Scop := Protected_Body_Subprogram (Scop);
end if;