Commit 94bbf008 by Arnaud Charlet

[multiple changes]

2011-09-05  Hristian Kirtchev  <kirtchev@adacore.com>

	* einfo.adb (Write_Field28_Name): Update the choices for
	Extra_Formals.
	* einfo.ads: Update the use of Extra_Formals in various entities.
	* exp_ch6.adb (Add_Task_Actuals_To_Build_In_Place_Call): Code
	reformatting. Handle the case where the function call returns
	an incomplete type coming from a limited with context. Generate
	a reference to the _master when the master id is associated
	with an access type.
	(Is_Build_In_Place_Function_Call): Code
	reformatting. The Alfa mode case must appear first since otherwise
	we will carry out the function name retrieval regardless of the
	compilation mode.
	(Make_Build_In_Place_Call_In_Allocator): Code
	reformatting. Handle the case where the function call returns
	an incomplete type coming from a limited with context. Remove
	the reference creation when adding the task-related actuals,
	this is now done in Add_Task_Actuals_To_Build_In_Place_Call.
	* exp_ch7.adb (Make_Set_Finalize_Address_Call): Remove local
	variable Call. Remove the useless wrapping of Set_Finalize_Address
	when the finalization master is a build-in-place extra formal. The
	whole mechanism of controlled allocation in a build-in-place
	context is already protected by an if statement.
	* sem_aux.adb (Is_Immutably_Limited_Type): Handle the case
	where the type might be related to a function which returns an
	incomplete type coming from a limited with.
	* sem_ch6.adb (Create_Extra_Formals): Comment
	reformatting. Handle the case where the function returns an
	incomplete type coming from a limited with context.

2011-09-05  Johannes Kanig  <kanig@adacore.com>

	* lib-xref-alfa.adb (Is_Alfa_Reference): Improve test for constant
	objects and rewrite case statement as /if/elsif/endif.

2011-09-05  Thomas Quinot  <quinot@adacore.com>

	* sem_ch3.adb, sem_ch4.adb: Minor reformatting.

From-SVN: r178537
parent aeae67ed
...@@ -8686,9 +8686,12 @@ package body Einfo is ...@@ -8686,9 +8686,12 @@ package body Einfo is
procedure Write_Field28_Name (Id : Entity_Id) is procedure Write_Field28_Name (Id : Entity_Id) is
begin begin
case Ekind (Id) is case Ekind (Id) is
when E_Procedure | when E_Entry |
E_Entry_Family |
E_Function | E_Function |
E_Entry => E_Procedure |
E_Subprogram_Body |
E_Subprogram_Type =>
Write_Str ("Extra_Formals"); Write_Str ("Extra_Formals");
when E_Record_Type => when E_Record_Type =>
......
...@@ -5137,6 +5137,7 @@ package Einfo is ...@@ -5137,6 +5137,7 @@ package Einfo is
-- Protection_Object (Node23) (protected kind) -- Protection_Object (Node23) (protected kind)
-- Contract (Node24) (for entry only) -- Contract (Node24) (for entry only)
-- PPC_Wrapper (Node25) -- PPC_Wrapper (Node25)
-- Extra_Formals (Node28)
-- Default_Expressions_Processed (Flag108) -- Default_Expressions_Processed (Flag108)
-- Entry_Accepted (Flag152) -- Entry_Accepted (Flag152)
-- Is_AST_Entry (Flag132) (for entry only) -- Is_AST_Entry (Flag132) (for entry only)
...@@ -5670,10 +5671,12 @@ package Einfo is ...@@ -5670,10 +5671,12 @@ package Einfo is
-- Corresponding_Protected_Entry (Node18) -- Corresponding_Protected_Entry (Node18)
-- Last_Entity (Node20) -- Last_Entity (Node20)
-- Scope_Depth_Value (Uint22) -- Scope_Depth_Value (Uint22)
-- Extra_Formals (Node28)
-- Scope_Depth (synth) -- Scope_Depth (synth)
-- E_Subprogram_Type -- E_Subprogram_Type
-- Directly_Designated_Type (Node20) -- Directly_Designated_Type (Node20)
-- Extra_Formals (Node28)
-- First_Formal (synth) -- First_Formal (synth)
-- First_Formal_With_Extras (synth) -- First_Formal_With_Extras (synth)
-- Last_Formal (synth) -- Last_Formal (synth)
......
...@@ -469,7 +469,7 @@ package body Exp_Ch6 is ...@@ -469,7 +469,7 @@ package body Exp_Ch6 is
begin begin
-- No such extra parameters are needed if there are no tasks -- No such extra parameters are needed if there are no tasks
if not Has_Task (Etype (Function_Id)) then if not Has_Task (Available_View (Etype (Function_Id))) then
return; return;
end if; end if;
...@@ -477,6 +477,12 @@ package body Exp_Ch6 is ...@@ -477,6 +477,12 @@ package body Exp_Ch6 is
if Restriction_Active (No_Task_Hierarchy) then if Restriction_Active (No_Task_Hierarchy) then
Actual := New_Occurrence_Of (RTE (RE_Library_Task_Level), Loc); Actual := New_Occurrence_Of (RTE (RE_Library_Task_Level), Loc);
-- In the case where we use the master associated with an access type,
-- the actual is an entity and requires an explicit reference.
elsif Nkind (Actual) = N_Defining_Identifier then
Actual := New_Reference_To (Actual, Loc);
end if; end if;
-- The master -- The master
...@@ -493,8 +499,7 @@ package body Exp_Ch6 is ...@@ -493,8 +499,7 @@ package body Exp_Ch6 is
-- Build the parameter association for the new actual and add it to -- Build the parameter association for the new actual and add it to
-- the end of the function's actuals. -- the end of the function's actuals.
Add_Extra_Actual_To_Call Add_Extra_Actual_To_Call (Function_Call, Master_Formal, Actual);
(Function_Call, Master_Formal, Actual);
end; end;
-- The activation chain -- The activation chain
...@@ -506,8 +511,8 @@ package body Exp_Ch6 is ...@@ -506,8 +511,8 @@ package body Exp_Ch6 is
begin begin
-- Locate implicit activation chain parameter in the called function -- Locate implicit activation chain parameter in the called function
Activation_Chain_Formal := Build_In_Place_Formal Activation_Chain_Formal :=
(Function_Id, BIP_Activation_Chain); Build_In_Place_Formal (Function_Id, BIP_Activation_Chain);
-- Create the actual which is a pointer to the current activation -- Create the actual which is a pointer to the current activation
-- chain -- chain
...@@ -6814,8 +6819,8 @@ package body Exp_Ch6 is ...@@ -6814,8 +6819,8 @@ package body Exp_Ch6 is
-- Step past qualification or unchecked conversion (the latter can occur -- Step past qualification or unchecked conversion (the latter can occur
-- in cases of calls to 'Input). -- in cases of calls to 'Input).
if Nkind_In if Nkind_In (Exp_Node, N_Qualified_Expression,
(Exp_Node, N_Qualified_Expression, N_Unchecked_Type_Conversion) N_Unchecked_Type_Conversion)
then then
Exp_Node := Expression (N); Exp_Node := Expression (N);
end if; end if;
...@@ -6824,19 +6829,22 @@ package body Exp_Ch6 is ...@@ -6824,19 +6829,22 @@ package body Exp_Ch6 is
return False; return False;
else else
if Is_Entity_Name (Name (Exp_Node)) then -- In Alfa mode, build-in-place calls are not expanded, so that we
-- may end up with a call that is neither resolved to an entity, nor
-- an indirect call.
if Alfa_Mode then
return False;
elsif Is_Entity_Name (Name (Exp_Node)) then
Function_Id := Entity (Name (Exp_Node)); Function_Id := Entity (Name (Exp_Node));
-- In the case of an explicitly dereferenced call, use the subprogram
-- type generated for the dereference.
elsif Nkind (Name (Exp_Node)) = N_Explicit_Dereference then elsif Nkind (Name (Exp_Node)) = N_Explicit_Dereference then
Function_Id := Etype (Name (Exp_Node)); Function_Id := Etype (Name (Exp_Node));
-- In Alfa mode, protected subprogram calls are not expanded, so that
-- we may end up with a call that is neither resolved to an entity,
-- nor an indirect call.
elsif Alfa_Mode then
return False;
else else
raise Program_Error; raise Program_Error;
end if; end if;
...@@ -7092,11 +7100,11 @@ package body Exp_Ch6 is ...@@ -7092,11 +7100,11 @@ package body Exp_Ch6 is
(Allocator : Node_Id; (Allocator : Node_Id;
Function_Call : Node_Id) Function_Call : Node_Id)
is is
Acc_Type : constant Entity_Id := Etype (Allocator);
Loc : Source_Ptr; Loc : Source_Ptr;
Func_Call : Node_Id := Function_Call; Func_Call : Node_Id := Function_Call;
Function_Id : Entity_Id; Function_Id : Entity_Id;
Result_Subt : Entity_Id; Result_Subt : Entity_Id;
Acc_Type : constant Entity_Id := Etype (Allocator);
New_Allocator : Node_Id; New_Allocator : Node_Id;
Return_Obj_Access : Entity_Id; Return_Obj_Access : Entity_Id;
...@@ -7135,7 +7143,7 @@ package body Exp_Ch6 is ...@@ -7135,7 +7143,7 @@ package body Exp_Ch6 is
raise Program_Error; raise Program_Error;
end if; end if;
Result_Subt := Etype (Function_Id); Result_Subt := Available_View (Etype (Function_Id));
-- Check whether return type includes tasks. This may not have been done -- Check whether return type includes tasks. This may not have been done
-- previously, if the type was a limited view. -- previously, if the type was a limited view.
...@@ -7236,17 +7244,8 @@ package body Exp_Ch6 is ...@@ -7236,17 +7244,8 @@ package body Exp_Ch6 is
Add_Finalization_Master_Actual_To_Build_In_Place_Call Add_Finalization_Master_Actual_To_Build_In_Place_Call
(Func_Call, Function_Id, Acc_Type); (Func_Call, Function_Id, Acc_Type);
-- If access type has a master entity, pass a reference to it Add_Task_Actuals_To_Build_In_Place_Call
(Func_Call, Function_Id, Master_Actual => Master_Id (Acc_Type));
if Present (Master_Id (Acc_Type)) then
Add_Task_Actuals_To_Build_In_Place_Call
(Func_Call, Function_Id,
Master_Actual =>
New_Occurrence_Of (Master_Id (Acc_Type), Loc));
else
Add_Task_Actuals_To_Build_In_Place_Call
(Func_Call, Function_Id, Empty);
end if;
-- The caller does not provide the return object in this case, so we -- The caller does not provide the return object in this case, so we
-- have to pass null for the object access actual. -- have to pass null for the object access actual.
......
...@@ -7461,7 +7461,6 @@ package body Exp_Ch7 is ...@@ -7461,7 +7461,6 @@ package body Exp_Ch7 is
Desig_Typ : constant Entity_Id := Desig_Typ : constant Entity_Id :=
Available_View (Designated_Type (Ptr_Typ)); Available_View (Designated_Type (Ptr_Typ));
Fin_Mas_Id : constant Entity_Id := Finalization_Master (Ptr_Typ); Fin_Mas_Id : constant Entity_Id := Finalization_Master (Ptr_Typ);
Call : Node_Id;
Fin_Mas_Ref : Node_Id; Fin_Mas_Ref : Node_Id;
Utyp : Entity_Id; Utyp : Entity_Id;
...@@ -7526,7 +7525,7 @@ package body Exp_Ch7 is ...@@ -7526,7 +7525,7 @@ package body Exp_Ch7 is
-- Generate: -- Generate:
-- Set_Finalize_Address (<Ptr_Typ>FM, <Utyp>FD'Unrestricted_Access); -- Set_Finalize_Address (<Ptr_Typ>FM, <Utyp>FD'Unrestricted_Access);
Call := return
Make_Procedure_Call_Statement (Loc, Make_Procedure_Call_Statement (Loc,
Name => Name =>
New_Reference_To (RTE (RE_Set_Finalize_Address), Loc), New_Reference_To (RTE (RE_Set_Finalize_Address), Loc),
...@@ -7536,25 +7535,6 @@ package body Exp_Ch7 is ...@@ -7536,25 +7535,6 @@ package body Exp_Ch7 is
Prefix => Prefix =>
New_Reference_To (TSS (Utyp, TSS_Finalize_Address), Loc), New_Reference_To (TSS (Utyp, TSS_Finalize_Address), Loc),
Attribute_Name => Name_Unrestricted_Access))); Attribute_Name => Name_Unrestricted_Access)));
-- In the case of build-in-place functions, protect the call to ensure
-- we have a master at run time. Generate:
-- if <Ptr_Typ>FM /= null then
-- <Call>;
-- end if;
if Is_Access_Type (Etype (Fin_Mas_Id)) then
Call :=
Make_If_Statement (Loc,
Condition =>
Make_Op_Ne (Loc,
Left_Opnd => New_Reference_To (Fin_Mas_Id, Loc),
Right_Opnd => Make_Null (Loc)),
Then_Statements => New_List (Call));
end if;
return Call;
end Make_Set_Finalize_Address_Call; end Make_Set_Finalize_Address_Call;
-------------------------- --------------------------
......
...@@ -604,38 +604,36 @@ package body Alfa is ...@@ -604,38 +604,36 @@ package body Alfa is
Typ : Character) return Boolean Typ : Character) return Boolean
is is
begin begin
-- The only references of interest on callable entities are calls.
-- On non-callable entities, the only references of interest are
-- reads and writes.
case Ekind (E) is if Ekind (E) in Overloadable_Kind then
when Overloadable_Kind =>
return Typ = 's';
-- References to IN parameters and constants are not -- The only references of interest on callable entities are
-- considered in Alfa section, as these will be translated -- calls. On non-callable entities, the only references of
-- as constants in the intermediate language for formal -- interest are reads and writes.
-- verification, and should therefore never appear in frame
-- conditions.
-- What about E_Loop_Parameter??? return Typ = 's';
elsif Is_Constant_Object (E) then
-- References to constant objects are not considered in Alfa
-- section, as these will be translated as constants in the
-- intermediate language for formal verification, and should
-- therefore never appear in frame conditions.
when E_In_Parameter | E_Constant =>
return False; return False;
when others => elsif Present (Etype (E)) and then
Ekind (Etype (E)) in Concurrent_Kind then
-- Objects of Task type or protected type are not Alfa -- Objects of Task type or protected type are not Alfa
-- references. -- references.
if Present (Etype (E)) return False;
and then Ekind (Etype (E)) in Concurrent_Kind
then
return False;
end if;
return Typ = 'r' or else Typ = 'm'; else
end case; return Typ = 'r' or else Typ = 'm';
end if;
end Is_Alfa_Reference; end Is_Alfa_Reference;
------------------- -------------------
......
...@@ -597,7 +597,7 @@ package body Sem_Aux is ...@@ -597,7 +597,7 @@ package body Sem_Aux is
------------------------------- -------------------------------
function Is_Immutably_Limited_Type (Ent : Entity_Id) return Boolean is function Is_Immutably_Limited_Type (Ent : Entity_Id) return Boolean is
Btype : constant Entity_Id := Base_Type (Ent); Btype : constant Entity_Id := Available_View (Base_Type (Ent));
begin begin
if Is_Limited_Record (Btype) then if Is_Limited_Record (Btype) then
...@@ -607,9 +607,8 @@ package body Sem_Aux is ...@@ -607,9 +607,8 @@ package body Sem_Aux is
and then Nkind (Parent (Btype)) = N_Formal_Type_Declaration and then Nkind (Parent (Btype)) = N_Formal_Type_Declaration
then then
return not In_Package_Body (Scope ((Btype))); return not In_Package_Body (Scope ((Btype)));
end if;
if Is_Private_Type (Btype) then elsif Is_Private_Type (Btype) then
-- AI05-0063: A type derived from a limited private formal type is -- AI05-0063: A type derived from a limited private formal type is
-- not immutably limited in a generic body. -- not immutably limited in a generic body.
......
...@@ -15061,6 +15061,7 @@ package body Sem_Ch3 is ...@@ -15061,6 +15061,7 @@ package body Sem_Ch3 is
Tag_Mismatch; Tag_Mismatch;
end if; end if;
end if; end if;
if Present (Prev) if Present (Prev)
and then Nkind (Parent (Prev)) = N_Incomplete_Type_Declaration and then Nkind (Parent (Prev)) = N_Incomplete_Type_Declaration
and then Present (Premature_Use (Parent (Prev))) and then Present (Premature_Use (Parent (Prev)))
......
...@@ -4322,7 +4322,7 @@ package body Sem_Ch4 is ...@@ -4322,7 +4322,7 @@ package body Sem_Ch4 is
Error_Msg_Node_2 := First_Subtype (Prefix_Type); Error_Msg_Node_2 := First_Subtype (Prefix_Type);
Error_Msg_NE ("no selector& for}", N, Sel); Error_Msg_NE ("no selector& for}", N, Sel);
-- If prefix is incomplete, add information -- Add information in the case of an incomplete prefix
if Is_Incomplete_Type (Type_To_Use) then if Is_Incomplete_Type (Type_To_Use) then
declare declare
...@@ -4340,6 +4340,10 @@ package body Sem_Ch4 is ...@@ -4340,6 +4340,10 @@ package body Sem_Ch4 is
if Nkind (Parent (Inc)) = if Nkind (Parent (Inc)) =
N_Incomplete_Type_Declaration N_Incomplete_Type_Declaration
then then
-- Record location of premature use in entity so that
-- a continuation message is generated when the
-- completion is seen.
Set_Premature_Use (Parent (Inc), N); Set_Premature_Use (Parent (Inc), N);
end if; end if;
end if; end if;
......
...@@ -6371,11 +6371,11 @@ package body Sem_Ch6 is ...@@ -6371,11 +6371,11 @@ package body Sem_Ch6 is
E, BIP_Formal_Suffix (BIP_Finalization_Master)); E, BIP_Formal_Suffix (BIP_Finalization_Master));
end if; end if;
-- If the result type contains tasks, we have two extra formals: -- When the result type contains tasks, add two extra formals: the
-- the master of the tasks to be created, and the caller's -- master of the tasks to be created, and the caller's activation
-- activation chain. -- chain.
if Has_Task (Result_Subt) then if Has_Task (Available_View (Result_Subt)) then
Discard := Discard :=
Add_Extra_Formal Add_Extra_Formal
(E, RTE (RE_Master_Id), (E, RTE (RE_Master_Id),
......
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