+2018-05-31 Ed Schonberg <schonberg@adacore.com>
+
+ * exp_unst.ads, exp_unst.adb (In_Synchronized_Unit): New predicate to
+ mark subprograms that cannot be eliminated because they must be treated
+ as reachable from outside the current unit. This includes entry bodies
+ and protected operations.
+
2018-05-31 Ed Schonberg <schonberg@adacore.com>
* exp_ch4.adb (Expand_Modular_Addition, Expand_Modular_Subtraction):
with Sinfo; use Sinfo;
with Sinput; use Sinput;
with Snames; use Snames;
+with Stand; use Stand;
with Tbuild; use Tbuild;
with Uintp; use Uintp;
end loop;
end Get_Level;
+ --------------------------
+ -- In_Synchronized_Unit --
+ --------------------------
+
+ function In_Synchronized_Unit (Subp : Entity_Id) return Boolean is
+ S : Entity_Id := Scope (Subp);
+
+ begin
+ while Present (S) and then S /= Standard_Standard loop
+ if Is_Concurrent_Type (S) then
+ return True;
+ end if;
+
+ S := Scope (S);
+ end loop;
+
+ return False;
+ end In_Synchronized_Unit;
+
----------------
-- Subp_Index --
----------------
Decl : Node_Id;
begin
+ -- Subprograms declared in tasks and protected types
+ -- are reachable and cannot be eliminated.
+
+ if In_Synchronized_Unit (STJ.Ent) then
+ STJ.Reachable := True;
+ end if;
+
-- Subprogram is reachable, copy and reset index
if STJ.Reachable then
-- function returns the level of nesting (Subp = 1, subprograms that
-- are immediately nested within Subp = 2, etc.).
+ function In_Synchronized_Unit (Subp : Entity_Id) return Boolean;
+ -- Predicate to identify subprograms declared in task and protected types.
+ -- These subprograms are called from outside the compilation and therefore
+ -- must be considered reachable (and cannot be eliminated) because we must
+ -- generate code for them.
+
function Subp_Index (Sub : Entity_Id) return SI_Type;
-- Given the entity for a subprogram, return corresponding Subp's index
procedure Unnest_Subprograms (N : Node_Id);
-- Called to unnest subprograms. If we are in unnest subprogram mode, this
- -- is the call that traverses the tree N and locates all the library level
+ -- is the call that traverses the tree N and locates all the library-level
-- subprograms with nested subprograms to process them.
end Exp_Unst;