Commit c364d9be by Javier Miranda Committed by Arnaud Charlet

exp_ch7.adb (Make_Clean): Code cleanup using the new centralized subprogram…

exp_ch7.adb (Make_Clean): Code cleanup using the new centralized subprogram Corresponding_Runtime_Package...

2008-03-26  Javier Miranda  <miranda@adacore.com>

	* exp_ch7.adb (Make_Clean): Code cleanup using the new centralized
	subprogram Corresponding_Runtime_Package to know the runtime package
	that will provide support to a given protected type.

	* exp_ch9.adb (Add_Private_Declarations,
	Build_Protected_Subprogram_Call,
	Build_Protected_Entry, Build_Simple_Entry_Call,
	Expand_N_Protected_Body, Expand_N_Protected_Type_Declaration,
	Expand_N_Timed_Entry_Call, Make_Initialize_Protection): Code
	cleanup using the new centralized subprogram Corresponding_Runtime
	Package to know the runtime package that provides support to
	a given protected type.

From-SVN: r133565
parent 1923d2d6
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2007, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2008, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -2301,14 +2301,16 @@ package body Exp_Ch7 is ...@@ -2301,14 +2301,16 @@ package body Exp_Ch7 is
if Nkind (Specification (N)) = N_Procedure_Specification if Nkind (Specification (N)) = N_Procedure_Specification
and then Has_Entries (Pid) and then Has_Entries (Pid)
then then
if Abort_Allowed case Corresponding_Runtime_Package (Pid) is
or else Restriction_Active (No_Entry_Queue) = False when System_Tasking_Protected_Objects_Entries =>
or else Number_Entries (Pid) > 1
then
Name := New_Reference_To (RTE (RE_Service_Entries), Loc); Name := New_Reference_To (RTE (RE_Service_Entries), Loc);
else
when System_Tasking_Protected_Objects_Single_Entry =>
Name := New_Reference_To (RTE (RE_Service_Entry), Loc); Name := New_Reference_To (RTE (RE_Service_Entry), Loc);
end if;
when others =>
raise Program_Error;
end case;
Append_To (Stmt, Append_To (Stmt,
Make_Procedure_Call_Statement (Loc, Make_Procedure_Call_Statement (Loc,
...@@ -2329,31 +2331,19 @@ package body Exp_Ch7 is ...@@ -2329,31 +2331,19 @@ package body Exp_Ch7 is
-- object is the record used to implement the protected object. -- object is the record used to implement the protected object.
-- It is a parameter to the protected subprogram. -- It is a parameter to the protected subprogram.
-- If the protected object is controlled (i.e it has entries or case Corresponding_Runtime_Package (Pid) is
-- needs finalization for interrupt handling), call when System_Tasking_Protected_Objects_Entries =>
-- Unlock_Entries, except if the protected object follows the
-- ravenscar profile, in which case call Unlock_Entry, otherwise
-- call the simplified version, Unlock.
if Has_Entries (Pid)
or else Has_Interrupt_Handler (Pid)
or else (Has_Attach_Handler (Pid)
and then not Restricted_Profile)
or else (Ada_Version >= Ada_05
and then Present (Interface_List (Parent (Pid))))
then
if Abort_Allowed
or else Restriction_Active (No_Entry_Queue) = False
or else Number_Entries (Pid) > 1
then
Name := New_Reference_To (RTE (RE_Unlock_Entries), Loc); Name := New_Reference_To (RTE (RE_Unlock_Entries), Loc);
else
when System_Tasking_Protected_Objects_Single_Entry =>
Name := New_Reference_To (RTE (RE_Unlock_Entry), Loc); Name := New_Reference_To (RTE (RE_Unlock_Entry), Loc);
end if;
else when System_Tasking_Protected_Objects =>
Name := New_Reference_To (RTE (RE_Unlock), Loc); Name := New_Reference_To (RTE (RE_Unlock), Loc);
end if;
when others =>
raise Program_Error;
end case;
Append_To (Stmt, Append_To (Stmt,
Make_Procedure_Call_Statement (Loc, Make_Procedure_Call_Statement (Loc,
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2007, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2008, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -666,7 +666,7 @@ package body Exp_Ch9 is ...@@ -666,7 +666,7 @@ package body Exp_Ch9 is
Expression => Expression =>
Unchecked_Convert_To (Obj_Ptr, Unchecked_Convert_To (Obj_Ptr,
Make_Identifier (Loc, Name_uO))); Make_Identifier (Loc, Name_uO)));
Set_Needs_Debug_Info (Defining_Identifier (Decl)); Set_Debug_Info_Needed (Defining_Identifier (Decl));
Prepend_To (Decls, Decl); Prepend_To (Decls, Decl);
Prepend_To (Decls, Prepend_To (Decls,
...@@ -703,10 +703,16 @@ package body Exp_Ch9 is ...@@ -703,10 +703,16 @@ package body Exp_Ch9 is
while Present (Formal) loop while Present (Formal) loop
Comp := Entry_Component (Formal); Comp := Entry_Component (Formal);
New_F := New_F :=
Make_Defining_Identifier (Sloc (Formal), Chars (Formal)); Make_Defining_Identifier (Sloc (Formal),
Chars => Chars (Formal));
Set_Etype (New_F, Etype (Formal)); Set_Etype (New_F, Etype (Formal));
Set_Scope (New_F, Ent); Set_Scope (New_F, Ent);
Set_Needs_Debug_Info (New_F); -- That's the whole point.
-- Now we set debug info needed on New_F even though it does not
-- come from source, so that the debugger will get the right
-- information for these generated names.
Set_Debug_Info_Needed (New_F);
if Ekind (Formal) = E_In_Parameter then if Ekind (Formal) = E_In_Parameter then
Set_Ekind (New_F, E_Constant); Set_Ekind (New_F, E_Constant);
...@@ -779,7 +785,7 @@ package body Exp_Ch9 is ...@@ -779,7 +785,7 @@ package body Exp_Ch9 is
Make_Selected_Component (Loc, Make_Selected_Component (Loc,
Prefix => Make_Identifier (Loc, Name), Prefix => Make_Identifier (Loc, Name),
Selector_Name => Make_Identifier (Loc, Chars (Pdef)))); Selector_Name => Make_Identifier (Loc, Chars (Pdef))));
Set_Needs_Debug_Info (Defining_Identifier (Decl)); Set_Debug_Info_Needed (Defining_Identifier (Decl));
Prepend_To (Decls, Decl); Prepend_To (Decls, Decl);
end if; end if;
...@@ -793,6 +799,8 @@ package body Exp_Ch9 is ...@@ -793,6 +799,8 @@ package body Exp_Ch9 is
Protection_Type : RE_Id; Protection_Type : RE_Id;
begin begin
-- Could this be simplified using Corresponding_Runtime_Package???
if Has_Attach_Handler (Typ) then if Has_Attach_Handler (Typ) then
if Restricted_Profile then if Restricted_Profile then
if Has_Entries (Typ) then if Has_Entries (Typ) then
...@@ -814,14 +822,16 @@ package body Exp_Ch9 is ...@@ -814,14 +822,16 @@ package body Exp_Ch9 is
or else (Ada_Version >= Ada_05 or else (Ada_Version >= Ada_05
and then Present (Interface_List (Parent (Typ)))) and then Present (Interface_List (Parent (Typ))))
then then
if Abort_Allowed case Corresponding_Runtime_Package (Typ) is
or else Restriction_Active (No_Entry_Queue) = False when System_Tasking_Protected_Objects_Entries =>
or else Number_Entries (Typ) > 1
then
Protection_Type := RE_Protection_Entries; Protection_Type := RE_Protection_Entries;
else
when System_Tasking_Protected_Objects_Single_Entry =>
Protection_Type := RE_Protection_Entry; Protection_Type := RE_Protection_Entry;
end if;
when others =>
raise Program_Error;
end case;
else else
Protection_Type := RE_Protection; Protection_Type := RE_Protection;
...@@ -839,7 +849,7 @@ package body Exp_Ch9 is ...@@ -839,7 +849,7 @@ package body Exp_Ch9 is
Make_Selected_Component (Loc, Make_Selected_Component (Loc,
Prefix => Make_Identifier (Loc, Name), Prefix => Make_Identifier (Loc, Name),
Selector_Name => Make_Identifier (Loc, Name_uObject))); Selector_Name => Make_Identifier (Loc, Name_uObject)));
Set_Needs_Debug_Info (Defining_Identifier (Decl)); Set_Debug_Info_Needed (Defining_Identifier (Decl));
Prepend_To (Decls, Decl); Prepend_To (Decls, Decl);
end; end;
end Add_Private_Declarations; end Add_Private_Declarations;
...@@ -1080,7 +1090,7 @@ package body Exp_Ch9 is ...@@ -1080,7 +1090,7 @@ package body Exp_Ch9 is
Loc : Source_Ptr) return Node_Id Loc : Source_Ptr) return Node_Id
is is
begin begin
Set_Needs_Debug_Info (Def_Id); Set_Debug_Info_Needed (Def_Id);
return Make_Function_Specification (Loc, return Make_Function_Specification (Loc,
Defining_Unit_Name => Def_Id, Defining_Unit_Name => Def_Id,
Parameter_Specifications => New_List ( Parameter_Specifications => New_List (
...@@ -2147,16 +2157,18 @@ package body Exp_Ch9 is ...@@ -2147,16 +2157,18 @@ package body Exp_Ch9 is
Add_Formal_Renamings (Espec, Op_Decls, Ent, Loc); Add_Formal_Renamings (Espec, Op_Decls, Ent, Loc);
if Abort_Allowed case Corresponding_Runtime_Package (Pid) is
or else Restriction_Active (No_Entry_Queue) = False when System_Tasking_Protected_Objects_Entries =>
or else Number_Entries (Pid) > 1 Complete :=
or else (Has_Attach_Handler (Pid) and then not Restricted_Profile) New_Reference_To (RTE (RE_Complete_Entry_Body), Loc);
then
Complete := New_Reference_To (RTE (RE_Complete_Entry_Body), Loc); when System_Tasking_Protected_Objects_Single_Entry =>
else
Complete := Complete :=
New_Reference_To (RTE (RE_Complete_Single_Entry_Body), Loc); New_Reference_To (RTE (RE_Complete_Single_Entry_Body), Loc);
end if;
when others =>
raise Program_Error;
end case;
Op_Stats := New_List ( Op_Stats := New_List (
Make_Block_Statement (Loc, Make_Block_Statement (Loc,
...@@ -2194,18 +2206,20 @@ package body Exp_Ch9 is ...@@ -2194,18 +2206,20 @@ package body Exp_Ch9 is
Ohandle := Make_Others_Choice (Loc); Ohandle := Make_Others_Choice (Loc);
Set_All_Others (Ohandle); Set_All_Others (Ohandle);
if Abort_Allowed case Corresponding_Runtime_Package (Pid) is
or else Restriction_Active (No_Entry_Queue) = False when System_Tasking_Protected_Objects_Entries =>
or else Number_Entries (Pid) > 1
or else (Has_Attach_Handler (Pid) and then not Restricted_Profile)
then
Complete := Complete :=
New_Reference_To (RTE (RE_Exceptional_Complete_Entry_Body), Loc); New_Reference_To
(RTE (RE_Exceptional_Complete_Entry_Body), Loc);
else when System_Tasking_Protected_Objects_Single_Entry =>
Complete := New_Reference_To ( Complete :=
RTE (RE_Exceptional_Complete_Single_Entry_Body), Loc); New_Reference_To
end if; (RTE (RE_Exceptional_Complete_Single_Entry_Body), Loc);
when others =>
raise Program_Error;
end case;
-- Create body of entry procedure. The renaming declarations are -- Create body of entry procedure. The renaming declarations are
-- placed ahead of the block that contains the actual entry body. -- placed ahead of the block that contains the actual entry body.
...@@ -2253,7 +2267,7 @@ package body Exp_Ch9 is ...@@ -2253,7 +2267,7 @@ package body Exp_Ch9 is
P : Entity_Id; P : Entity_Id;
begin begin
Set_Needs_Debug_Info (Def_Id); Set_Debug_Info_Needed (Def_Id);
P := Make_Defining_Identifier (Loc, Name_uP); P := Make_Defining_Identifier (Loc, Name_uP);
if Present (Ent_Id) then if Present (Ent_Id) then
...@@ -2329,7 +2343,7 @@ package body Exp_Ch9 is ...@@ -2329,7 +2343,7 @@ package body Exp_Ch9 is
(Etype (Ident) = Standard_Void_Type (Etype (Ident) = Standard_Void_Type
and then not Is_RTE (Obj_Type, RE_Address)), and then not Is_RTE (Obj_Type, RE_Address)),
Parameter_Type => New_Reference_To (Obj_Type, Loc)); Parameter_Type => New_Reference_To (Obj_Type, Loc));
Set_Needs_Debug_Info (Defining_Identifier (Decl)); Set_Debug_Info_Needed (Defining_Identifier (Decl));
Prepend_To (New_Plist, Decl); Prepend_To (New_Plist, Decl);
return New_Plist; return New_Plist;
...@@ -2382,7 +2396,7 @@ package body Exp_Ch9 is ...@@ -2382,7 +2396,7 @@ package body Exp_Ch9 is
-- into the protected operation, even though it only contains lock/ -- into the protected operation, even though it only contains lock/
-- unlock calls. -- unlock calls.
Set_Needs_Debug_Info (New_Id); Set_Debug_Info_Needed (New_Id);
if Nkind (Specification (Decl)) = N_Procedure_Specification then if Nkind (Specification (Decl)) = N_Procedure_Specification then
return return
...@@ -2596,36 +2610,22 @@ package body Exp_Ch9 is ...@@ -2596,36 +2610,22 @@ package body Exp_Ch9 is
-- Make the protected subprogram body. This locks the protected -- Make the protected subprogram body. This locks the protected
-- object and calls the unprotected version of the subprogram. -- object and calls the unprotected version of the subprogram.
-- If the protected object is controlled (i.e it has entries or case Corresponding_Runtime_Package (Pid) is
-- needs finalization for interrupt handling), call Lock_Entries, when System_Tasking_Protected_Objects_Entries =>
-- except if the protected object follows the Ravenscar profile, in
-- which case call Lock_Entry, otherwise call the simplified version,
-- Lock.
if Has_Entries (Pid)
or else Has_Interrupt_Handler (Pid)
or else (Has_Attach_Handler (Pid)
and then not Restricted_Profile)
or else (Ada_Version >= Ada_05
and then Present (Interface_List (Parent (Pid))))
then
if Abort_Allowed
or else Restriction_Active (No_Entry_Queue) = False
or else Number_Entries (Pid) > 1
or else (Has_Attach_Handler (Pid) and then not Restricted_Profile)
then
Lock_Name := New_Reference_To (RTE (RE_Lock_Entries), Loc); Lock_Name := New_Reference_To (RTE (RE_Lock_Entries), Loc);
Service_Name := New_Reference_To (RTE (RE_Service_Entries), Loc); Service_Name := New_Reference_To (RTE (RE_Service_Entries), Loc);
else when System_Tasking_Protected_Objects_Single_Entry =>
Lock_Name := New_Reference_To (RTE (RE_Lock_Entry), Loc); Lock_Name := New_Reference_To (RTE (RE_Lock_Entry), Loc);
Service_Name := New_Reference_To (RTE (RE_Service_Entry), Loc); Service_Name := New_Reference_To (RTE (RE_Service_Entry), Loc);
end if;
else when System_Tasking_Protected_Objects =>
Lock_Name := New_Reference_To (RTE (RE_Lock), Loc); Lock_Name := New_Reference_To (RTE (RE_Lock), Loc);
Service_Name := New_Reference_To (RTE (RE_Unlock), Loc); Service_Name := New_Reference_To (RTE (RE_Unlock), Loc);
end if;
when others =>
raise Program_Error;
end case;
Object_Parm := Object_Parm :=
Make_Attribute_Reference (Loc, Make_Attribute_Reference (Loc,
...@@ -3101,12 +3101,9 @@ package body Exp_Ch9 is ...@@ -3101,12 +3101,9 @@ package body Exp_Ch9 is
-- Now we can create the call, case of protected type -- Now we can create the call, case of protected type
if Is_Protected_Type (Conctyp) then if Is_Protected_Type (Conctyp) then
if Abort_Allowed case Corresponding_Runtime_Package (Conctyp) is
or else Restriction_Active (No_Entry_Queue) = False when System_Tasking_Protected_Objects_Entries =>
or else Number_Entries (Conctyp) > 1
or else (Has_Attach_Handler (Conctyp)
and then not Restricted_Profile)
then
-- Change the type of the index declaration -- Change the type of the index declaration
Set_Object_Definition (Xdecl, Set_Object_Definition (Xdecl,
...@@ -3152,7 +3149,7 @@ package body Exp_Ch9 is ...@@ -3152,7 +3149,7 @@ package body Exp_Ch9 is
New_Reference_To (RTE (RE_Simple_Call), Loc), New_Reference_To (RTE (RE_Simple_Call), Loc),
New_Occurrence_Of (Comm_Name, Loc))); New_Occurrence_Of (Comm_Name, Loc)));
else when System_Tasking_Protected_Objects_Single_Entry =>
-- Protected_Single_Entry_Call ( -- Protected_Single_Entry_Call (
-- Object => po._object'Access, -- Object => po._object'Access,
-- Uninterpreted_Data => P'Address; -- Uninterpreted_Data => P'Address;
...@@ -3169,7 +3166,10 @@ package body Exp_Ch9 is ...@@ -3169,7 +3166,10 @@ package body Exp_Ch9 is
Prefix => Parm1), Prefix => Parm1),
Parm3, Parm3,
New_Reference_To (RTE (RE_Simple_Call), Loc))); New_Reference_To (RTE (RE_Simple_Call), Loc)));
end if;
when others =>
raise Program_Error;
end case;
-- Case of task type -- Case of task type
...@@ -4185,7 +4185,7 @@ package body Exp_Ch9 is ...@@ -4185,7 +4185,7 @@ package body Exp_Ch9 is
if Present (Ann) then if Present (Ann) then
Append_Elmt (Ann, Accept_Address (Ent)); Append_Elmt (Ann, Accept_Address (Ent));
Set_Needs_Debug_Info (Ann); Set_Debug_Info_Needed (Ann);
end if; end if;
-- Create renaming declarations for the entry formals. Each reference -- Create renaming declarations for the entry formals. Each reference
...@@ -4215,7 +4215,12 @@ package body Exp_Ch9 is ...@@ -4215,7 +4215,12 @@ package body Exp_Ch9 is
Set_Etype (New_F, Etype (Formal)); Set_Etype (New_F, Etype (Formal));
Set_Scope (New_F, Ent); Set_Scope (New_F, Ent);
Set_Needs_Debug_Info (New_F); -- That's the whole point.
-- Now we set debug info needed on New_F even though it does
-- not come from source, so that the debugger will get the
-- right information for these generated names.
Set_Debug_Info_Needed (New_F);
if Ekind (Formal) = E_In_Parameter then if Ekind (Formal) = E_In_Parameter then
Set_Ekind (New_F, E_Constant); Set_Ekind (New_F, E_Constant);
...@@ -6683,7 +6688,6 @@ package body Exp_Ch9 is ...@@ -6683,7 +6688,6 @@ package body Exp_Ch9 is
procedure Expand_N_Protected_Body (N : Node_Id) is procedure Expand_N_Protected_Body (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N); Loc : constant Source_Ptr := Sloc (N);
Pid : constant Entity_Id := Corresponding_Spec (N); Pid : constant Entity_Id := Corresponding_Spec (N);
Has_Entries : Boolean := False;
Op_Body : Node_Id; Op_Body : Node_Id;
Op_Decl : Node_Id; Op_Decl : Node_Id;
Op_Id : Entity_Id; Op_Id : Entity_Id;
...@@ -6893,7 +6897,6 @@ package body Exp_Ch9 is ...@@ -6893,7 +6897,6 @@ package body Exp_Ch9 is
when N_Entry_Body => when N_Entry_Body =>
Op_Id := Defining_Identifier (Op_Body); Op_Id := Defining_Identifier (Op_Body);
Has_Entries := True;
Num_Entries := Num_Entries + 1; Num_Entries := Num_Entries + 1;
New_Op_Body := Build_Protected_Entry (Op_Body, Op_Id, Pid); New_Op_Body := Build_Protected_Entry (Op_Body, Op_Id, Pid);
...@@ -6946,14 +6949,10 @@ package body Exp_Ch9 is ...@@ -6946,14 +6949,10 @@ package body Exp_Ch9 is
-- Finally, create the body of the function that maps an entry index -- Finally, create the body of the function that maps an entry index
-- into the corresponding body index, except when there is no entry, -- into the corresponding body index, except when there is no entry,
-- or in a ravenscar-like profile (no abort, no entry queue, 1 entry) -- or in a ravenscar-like profile.
if Has_Entries if Corresponding_Runtime_Package (Pid) =
and then (Abort_Allowed System_Tasking_Protected_Objects_Entries
or else Restriction_Active (No_Entry_Queue) = False
or else Num_Entries > 1
or else (Has_Attach_Handler (Pid)
and then not Restricted_Profile))
then then
New_Op_Body := Build_Find_Body_Index (Pid); New_Op_Body := Build_Find_Body_Index (Pid);
Insert_After (Current_Node, New_Op_Body); Insert_After (Current_Node, New_Op_Body);
...@@ -7219,11 +7218,13 @@ package body Exp_Ch9 is ...@@ -7219,11 +7218,13 @@ package body Exp_Ch9 is
(Prottyp, Cdecls, Loc); (Prottyp, Cdecls, Loc);
begin begin
-- Could this be simplified using Corresponding_Runtime_Package???
if Has_Attach_Handler (Prottyp) then if Has_Attach_Handler (Prottyp) then
Ritem := First_Rep_Item (Prottyp); Ritem := First_Rep_Item (Prottyp);
while Present (Ritem) loop while Present (Ritem) loop
if Nkind (Ritem) = N_Pragma if Nkind (Ritem) = N_Pragma
and then Chars (Ritem) = Name_Attach_Handler and then Pragma_Name (Ritem) = Name_Attach_Handler
then then
Num_Attach_Handler := Num_Attach_Handler + 1; Num_Attach_Handler := Num_Attach_Handler + 1;
end if; end if;
...@@ -7271,13 +7272,10 @@ package body Exp_Ch9 is ...@@ -7271,13 +7272,10 @@ package body Exp_Ch9 is
or else (Ada_Version >= Ada_05 or else (Ada_Version >= Ada_05
and then Present (Interface_List (N))) and then Present (Interface_List (N)))
then then
if Abort_Allowed case Corresponding_Runtime_Package (Prottyp) is
or else Restriction_Active (No_Entry_Queue) = False when System_Tasking_Protected_Objects_Entries =>
or else Number_Entries (Prottyp) > 1
then
Protection_Subtype := Protection_Subtype :=
Make_Subtype_Indication ( Make_Subtype_Indication (Loc,
Sloc => Loc,
Subtype_Mark => Subtype_Mark =>
New_Reference_To (RTE (RE_Protection_Entries), Loc), New_Reference_To (RTE (RE_Protection_Entries), Loc),
Constraint => Constraint =>
...@@ -7285,10 +7283,13 @@ package body Exp_Ch9 is ...@@ -7285,10 +7283,13 @@ package body Exp_Ch9 is
Sloc => Loc, Sloc => Loc,
Constraints => New_List (Entry_Count_Expr))); Constraints => New_List (Entry_Count_Expr)));
else when System_Tasking_Protected_Objects_Single_Entry =>
Protection_Subtype := Protection_Subtype :=
New_Reference_To (RTE (RE_Protection_Entry), Loc); New_Reference_To (RTE (RE_Protection_Entry), Loc);
end if;
when others =>
raise Program_Error;
end case;
else else
Protection_Subtype := New_Reference_To (RTE (RE_Protection), Loc); Protection_Subtype := New_Reference_To (RTE (RE_Protection), Loc);
...@@ -7692,12 +7693,8 @@ package body Exp_Ch9 is ...@@ -7692,12 +7693,8 @@ package body Exp_Ch9 is
Body_Id := Make_Defining_Identifier (Sloc (Prottyp), Body_Id := Make_Defining_Identifier (Sloc (Prottyp),
New_External_Name (Chars (Prottyp), 'A')); New_External_Name (Chars (Prottyp), 'A'));
if Abort_Allowed case Corresponding_Runtime_Package (Prottyp) is
or else Restriction_Active (No_Entry_Queue) = False when System_Tasking_Protected_Objects_Entries =>
or else E_Count > 1
or else (Has_Attach_Handler (Prottyp)
and then not Restricted_Profile)
then
Body_Arr := Make_Object_Declaration (Loc, Body_Arr := Make_Object_Declaration (Loc,
Defining_Identifier => Body_Id, Defining_Identifier => Body_Id,
Aliased_Present => True, Aliased_Present => True,
...@@ -7713,11 +7710,12 @@ package body Exp_Ch9 is ...@@ -7713,11 +7710,12 @@ package body Exp_Ch9 is
Make_Integer_Literal (Loc, E_Count))))), Make_Integer_Literal (Loc, E_Count))))),
Expression => Entries_Aggr); Expression => Entries_Aggr);
else when System_Tasking_Protected_Objects_Single_Entry =>
Body_Arr := Make_Object_Declaration (Loc, Body_Arr := Make_Object_Declaration (Loc,
Defining_Identifier => Body_Id, Defining_Identifier => Body_Id,
Aliased_Present => True, Aliased_Present => True,
Object_Definition => New_Reference_To (RTE (RE_Entry_Body), Loc), Object_Definition => New_Reference_To
(RTE (RE_Entry_Body), Loc),
Expression => Expression =>
Make_Aggregate (Loc, Make_Aggregate (Loc,
Expressions => New_List ( Expressions => New_List (
...@@ -7727,7 +7725,10 @@ package body Exp_Ch9 is ...@@ -7727,7 +7725,10 @@ package body Exp_Ch9 is
Make_Attribute_Reference (Loc, Make_Attribute_Reference (Loc,
Prefix => New_Reference_To (Edef, Loc), Prefix => New_Reference_To (Edef, Loc),
Attribute_Name => Name_Unrestricted_Access)))); Attribute_Name => Name_Unrestricted_Access))));
end if;
when others =>
raise Program_Error;
end case;
-- A pointer to this array will be placed in the corresponding record -- A pointer to this array will be placed in the corresponding record
-- by its initialization procedure so this needs to be analyzed here. -- by its initialization procedure so this needs to be analyzed here.
...@@ -7743,11 +7744,8 @@ package body Exp_Ch9 is ...@@ -7743,11 +7744,8 @@ package body Exp_Ch9 is
-- object of the type. Except for a ravenscar-like profile (no abort, -- object of the type. Except for a ravenscar-like profile (no abort,
-- no entry queue, 1 entry) -- no entry queue, 1 entry)
if Abort_Allowed if Corresponding_Runtime_Package (Prottyp)
or else Restriction_Active (No_Entry_Queue) = False = System_Tasking_Protected_Objects_Entries
or else E_Count > 1
or else (Has_Attach_Handler (Prottyp)
and then not Restricted_Profile)
then then
Sub := Sub :=
Make_Subprogram_Declaration (Loc, Make_Subprogram_Declaration (Loc,
...@@ -8341,7 +8339,9 @@ package body Exp_Ch9 is ...@@ -8341,7 +8339,9 @@ package body Exp_Ch9 is
Make_Defining_Identifier (Sloc (Ename), Make_Defining_Identifier (Sloc (Ename),
New_External_Name (Chars (Ename), 'A', Num_Accept)); New_External_Name (Chars (Ename), 'A', Num_Accept));
Set_Needs_Debug_Info (PB_Ent, Comes_From_Source (Alt)); if Comes_From_Source (Alt) then
Set_Debug_Info_Needed (PB_Ent);
end if;
Proc_Body := Proc_Body :=
Make_Subprogram_Body (Loc, Make_Subprogram_Body (Loc,
...@@ -9685,7 +9685,7 @@ package body Exp_Ch9 is ...@@ -9685,7 +9685,7 @@ package body Exp_Ch9 is
-- the benefit of some versions of System.Interrupts which use -- the benefit of some versions of System.Interrupts which use
-- a special server task with maximum interrupt priority. -- a special server task with maximum interrupt priority.
if Chars (Prag) = Name_Priority if Pragma_Name (Prag) = Name_Priority
and then not GNAT_Mode and then not GNAT_Mode
then then
Rewrite (Expr, Convert_To (RTE (RE_Priority), Expr)); Rewrite (Expr, Convert_To (RTE (RE_Priority), Expr));
...@@ -9772,8 +9772,9 @@ package body Exp_Ch9 is ...@@ -9772,8 +9772,9 @@ package body Exp_Ch9 is
-- The subprogram does not comes from source, so we have to indicate the -- The subprogram does not comes from source, so we have to indicate the
-- need for debugging information explicitly. -- need for debugging information explicitly.
Set_Needs_Debug_Info if Comes_From_Source (Original_Node (N)) then
(Defining_Entity (Proc_Spec), Comes_From_Source (Original_Node (N))); Set_Debug_Info_Needed (Defining_Entity (Proc_Spec));
end if;
-- Ada 2005 (AI-345): Construct the primitive entry wrapper specs before -- Ada 2005 (AI-345): Construct the primitive entry wrapper specs before
-- the corresponding record has been frozen. -- the corresponding record has been frozen.
...@@ -10358,20 +10359,20 @@ package body Exp_Ch9 is ...@@ -10358,20 +10359,20 @@ package body Exp_Ch9 is
Append_To (Params, New_Reference_To (B, Loc)); Append_To (Params, New_Reference_To (B, Loc));
if Abort_Allowed case Corresponding_Runtime_Package (Etype (Concval)) is
or else Restriction_Active (No_Entry_Queue) = False when System_Tasking_Protected_Objects_Entries =>
or else Number_Entries (Etype (Concval)) > 1
then
Rewrite (Call, Rewrite (Call,
Make_Procedure_Call_Statement (Loc, Make_Procedure_Call_Statement (Loc,
Name => Name =>
New_Reference_To (RTE ( New_Reference_To
RE_Timed_Protected_Entry_Call), Loc), (RTE (RE_Timed_Protected_Entry_Call), Loc),
Parameter_Associations => Params)); Parameter_Associations => Params));
else
when System_Tasking_Protected_Objects_Single_Entry =>
Param := First (Params); Param := First (Params);
while Present (Param) while Present (Param)
and then not Is_RTE (Etype (Param), RE_Protected_Entry_Index) and then not
Is_RTE (Etype (Param), RE_Protected_Entry_Index)
loop loop
Next (Param); Next (Param);
end loop; end loop;
...@@ -10383,7 +10384,10 @@ package body Exp_Ch9 is ...@@ -10383,7 +10384,10 @@ package body Exp_Ch9 is
Name => New_Reference_To ( Name => New_Reference_To (
RTE (RE_Timed_Protected_Single_Entry_Call), Loc), RTE (RE_Timed_Protected_Single_Entry_Call), Loc),
Parameter_Associations => Params)); Parameter_Associations => Params));
end if;
when others =>
raise Program_Error;
end case;
-- For the task case, build a Timed_Task_Entry_Call -- For the task case, build a Timed_Task_Entry_Call
...@@ -10749,11 +10753,11 @@ package body Exp_Ch9 is ...@@ -10749,11 +10753,11 @@ package body Exp_Ch9 is
N := First (Visible_Declarations (T)); N := First (Visible_Declarations (T));
while Present (N) loop while Present (N) loop
if Nkind (N) = N_Pragma then if Nkind (N) = N_Pragma then
if Chars (N) = P then if Pragma_Name (N) = P then
return N; return N;
elsif P = Name_Priority elsif P = Name_Priority
and then Chars (N) = Name_Interrupt_Priority and then Pragma_Name (N) = Name_Interrupt_Priority
then then
return N; return N;
...@@ -10769,11 +10773,11 @@ package body Exp_Ch9 is ...@@ -10769,11 +10773,11 @@ package body Exp_Ch9 is
N := First (Private_Declarations (T)); N := First (Private_Declarations (T));
while Present (N) loop while Present (N) loop
if Nkind (N) = N_Pragma then if Nkind (N) = N_Pragma then
if Chars (N) = P then if Pragma_Name (N) = P then
return N; return N;
elsif P = Name_Priority elsif P = Name_Priority
and then Chars (N) = Name_Interrupt_Priority and then Pragma_Name (N) = Name_Interrupt_Priority
then then
return N; return N;
...@@ -11071,9 +11075,28 @@ package body Exp_Ch9 is ...@@ -11071,9 +11075,28 @@ package body Exp_Ch9 is
if Has_Entry if Has_Entry
or else Has_Interrupt_Handler (Ptyp) or else Has_Interrupt_Handler (Ptyp)
or else Has_Attach_Handler (Ptyp) or else Has_Attach_Handler (Ptyp)
or else (Ada_Version >= Ada_05 or else Has_Abstract_Interfaces (Protect_Rec)
and then Present (Interface_List (Parent (Ptyp))))
then then
declare
Pkg_Id : constant RTU_Id := Corresponding_Runtime_Package (Ptyp);
Called_Subp : RE_Id;
begin
case Pkg_Id is
when System_Tasking_Protected_Objects_Entries =>
Called_Subp := RE_Initialize_Protection_Entries;
when System_Tasking_Protected_Objects =>
Called_Subp := RE_Initialize_Protection;
when System_Tasking_Protected_Objects_Single_Entry =>
Called_Subp := RE_Initialize_Protection_Entry;
when others =>
raise Program_Error;
end case;
if Has_Entry or else not Restricted then if Has_Entry or else not Restricted then
Append_To (Args, Append_To (Args,
Make_Attribute_Reference (Loc, Make_Attribute_Reference (Loc,
...@@ -11081,10 +11104,10 @@ package body Exp_Ch9 is ...@@ -11081,10 +11104,10 @@ package body Exp_Ch9 is
Attribute_Name => Name_Address)); Attribute_Name => Name_Address));
end if; end if;
-- Entry_Bodies parameter. This is a pointer to an array of pointers -- Entry_Bodies parameter. This is a pointer to an array of
-- to the entry body procedures and barrier functions of the object. -- pointers to the entry body procedures and barrier functions of
-- If the protected type has no entries this object will not exist; -- the object. If the protected type has no entries this object
-- in this case, pass a null. -- will not exist, in this case, pass a null.
if Has_Entry then if Has_Entry then
P_Arr := Entry_Bodies_Array (Ptyp); P_Arr := Entry_Bodies_Array (Ptyp);
...@@ -11094,11 +11117,8 @@ package body Exp_Ch9 is ...@@ -11094,11 +11117,8 @@ package body Exp_Ch9 is
Prefix => New_Reference_To (P_Arr, Loc), Prefix => New_Reference_To (P_Arr, Loc),
Attribute_Name => Name_Unrestricted_Access)); Attribute_Name => Name_Unrestricted_Access));
if Abort_Allowed if Pkg_Id = System_Tasking_Protected_Objects_Entries then
or else Restriction_Active (No_Entry_Queue) = False
or else Number_Entries (Ptyp) > 1
or else (Has_Attach_Handler (Ptyp) and then not Restricted)
then
-- Find index mapping function (clumsy but ok for now) -- Find index mapping function (clumsy but ok for now)
while Ekind (P_Arr) /= E_Function loop while Ekind (P_Arr) /= E_Function loop
...@@ -11112,38 +11132,19 @@ package body Exp_Ch9 is ...@@ -11112,38 +11132,19 @@ package body Exp_Ch9 is
Attribute_Name => Name_Unrestricted_Access)); Attribute_Name => Name_Unrestricted_Access));
end if; end if;
elsif not Restricted then elsif Pkg_Id = System_Tasking_Protected_Objects_Single_Entry then
Append_To (Args, Make_Null (Loc));
elsif Pkg_Id = System_Tasking_Protected_Objects_Entries then
Append_To (Args, Make_Null (Loc)); Append_To (Args, Make_Null (Loc));
Append_To (Args, Make_Null (Loc)); Append_To (Args, Make_Null (Loc));
end if; end if;
if Abort_Allowed
or else Restriction_Active (No_Entry_Queue) = False
or else Number_Entries (Ptyp) > 1
or else (Has_Attach_Handler (Ptyp)
and then not Restricted)
then
Append_To (L,
Make_Procedure_Call_Statement (Loc,
Name => New_Reference_To (
RTE (RE_Initialize_Protection_Entries), Loc),
Parameter_Associations => Args));
elsif not Has_Entry and then Restricted then
Append_To (L,
Make_Procedure_Call_Statement (Loc,
Name => New_Reference_To (
RTE (RE_Initialize_Protection), Loc),
Parameter_Associations => Args));
else
Append_To (L, Append_To (L,
Make_Procedure_Call_Statement (Loc, Make_Procedure_Call_Statement (Loc,
Name => New_Reference_To ( Name => New_Reference_To (RTE (Called_Subp), Loc),
RTE (RE_Initialize_Protection_Entry), Loc),
Parameter_Associations => Args)); Parameter_Associations => Args));
end if; end;
else else
Append_To (L, Append_To (L,
Make_Procedure_Call_Statement (Loc, Make_Procedure_Call_Statement (Loc,
...@@ -11187,7 +11188,7 @@ package body Exp_Ch9 is ...@@ -11187,7 +11188,7 @@ package body Exp_Ch9 is
while Present (Ritem) loop while Present (Ritem) loop
if Nkind (Ritem) = N_Pragma if Nkind (Ritem) = N_Pragma
and then Chars (Ritem) = Name_Attach_Handler and then Pragma_Name (Ritem) = Name_Attach_Handler
then then
declare declare
Handler : constant Node_Id := Handler : constant Node_Id :=
...@@ -11473,9 +11474,11 @@ package body Exp_Ch9 is ...@@ -11473,9 +11474,11 @@ package body Exp_Ch9 is
and then (Nkind_In (Stmt, N_Null_Statement, N_Label) and then (Nkind_In (Stmt, N_Null_Statement, N_Label)
or else or else
(Nkind (Stmt) = N_Pragma (Nkind (Stmt) = N_Pragma
and then (Chars (Stmt) = Name_Unreferenced and then (Pragma_Name (Stmt) = Name_Unreferenced
or else
Pragma_Name (Stmt) = Name_Unmodified
or else or else
Chars (Stmt) = Name_Warnings))) Pragma_Name (Stmt) = Name_Warnings)))
loop loop
Next (Stmt); Next (Stmt);
end loop; end loop;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment