Commit 4ac2bbbd by Arnaud Charlet

[multiple changes]

2014-07-18  Hristian Kirtchev  <kirtchev@adacore.com>

	* einfo.adb Last_Aggregate_Assignment is now Node 30.
	(Last_Aggregate_Assignment): Include
	constants in the assertion. Update the underlying node.
	(Set_Last_Aggregate_Assignment): Include constants in the
	assertion. Update the underlying node.	(Write_Field11_Name):
	Remove the entry for Last_Aggregate_Assignment.
	(Write_Field30_Name): Add an entry for Last_Aggregate_Assignment.
	* einfo.ads Update the node designation and usage of attribute
	Last_Aggregate_Assignment.
	* exp_aggr.adb (Expand_Array_Aggregate): Store the last
	assignment statement used to initialize a controlled object.
	(Late_Expansion): Store the last assignment statement used to
	initialize a controlled record or an array of controlled objects.
	* exp_ch3.adb (Expand_N_Object_Declaration): Default
	initialization of objects is now performed in a separate routine.
	(Default_Initialize_Object): New routine.
	* exp_ch7.adb (Build_BIP_Cleanup_Stmts): Add formal parameter
	Obj_Id. Update the comment on usage.
	(Find_Last_Init): Remove formal parameter Typ. Update comment on usage.
	Reimplement the logic.	(Find_Last_Init_In_Block): New routine.
	(Is_Init_Call): Add formal parameter Init_Typ. Update the
	comment on usage.  Account for the type init proc when trying
	to determine whether a statement is an initialization call.
	(Make_Adjust_Call): Rename formal parameter For_Parent to
	Skip_Self. Update all occurrences of For_Parent. Account for
	non-tagged types. Update the call to Make_Call.
	(Make_Call): Rename formal parameter For_Parent to Skip_Self. Update
	comment on usage. Update all occurrences of For_Parent.
	(Make_Final_Call): Rename formal parameter For_Parent to
	Skip_Self. Update all occurrences of For_Parent. Account
	for non-tagged types. Update the call to Make_Call.
	(Process_Object_Declaration): Most variables and constants are
	now local to the routine.
	* exp_ch7.ads (Make_Adjust_Call): Rename formal parameter
	For_Parent to Skip_Self. Update the comment on usage.
	(Make_Final_Call): Rename formal parameter For_Parent to
	Skip_Self. Update the comment on usage.

2014-07-18  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch9.adb (Analyze_Requeue): The entry being referenced
	can be a procedure that is implemented by entry, and have a
	formal that is a synchronized interface.  It does not have to
	be declared as a protected operation.

From-SVN: r212814
parent 2941bf7d
2014-07-18 Hristian Kirtchev <kirtchev@adacore.com>
* einfo.adb Last_Aggregate_Assignment is now Node 30.
(Last_Aggregate_Assignment): Include
constants in the assertion. Update the underlying node.
(Set_Last_Aggregate_Assignment): Include constants in the
assertion. Update the underlying node. (Write_Field11_Name):
Remove the entry for Last_Aggregate_Assignment.
(Write_Field30_Name): Add an entry for Last_Aggregate_Assignment.
* einfo.ads Update the node designation and usage of attribute
Last_Aggregate_Assignment.
* exp_aggr.adb (Expand_Array_Aggregate): Store the last
assignment statement used to initialize a controlled object.
(Late_Expansion): Store the last assignment statement used to
initialize a controlled record or an array of controlled objects.
* exp_ch3.adb (Expand_N_Object_Declaration): Default
initialization of objects is now performed in a separate routine.
(Default_Initialize_Object): New routine.
* exp_ch7.adb (Build_BIP_Cleanup_Stmts): Add formal parameter
Obj_Id. Update the comment on usage.
(Find_Last_Init): Remove formal parameter Typ. Update comment on usage.
Reimplement the logic. (Find_Last_Init_In_Block): New routine.
(Is_Init_Call): Add formal parameter Init_Typ. Update the
comment on usage. Account for the type init proc when trying
to determine whether a statement is an initialization call.
(Make_Adjust_Call): Rename formal parameter For_Parent to
Skip_Self. Update all occurrences of For_Parent. Account for
non-tagged types. Update the call to Make_Call.
(Make_Call): Rename formal parameter For_Parent to Skip_Self. Update
comment on usage. Update all occurrences of For_Parent.
(Make_Final_Call): Rename formal parameter For_Parent to
Skip_Self. Update all occurrences of For_Parent. Account
for non-tagged types. Update the call to Make_Call.
(Process_Object_Declaration): Most variables and constants are
now local to the routine.
* exp_ch7.ads (Make_Adjust_Call): Rename formal parameter
For_Parent to Skip_Self. Update the comment on usage.
(Make_Final_Call): Rename formal parameter For_Parent to
Skip_Self. Update the comment on usage.
2014-07-18 Ed Schonberg <schonberg@adacore.com>
* sem_ch9.adb (Analyze_Requeue): The entry being referenced
can be a procedure that is implemented by entry, and have a
formal that is a synchronized interface. It does not have to
be declared as a protected operation.
2014-07-18 Robert Dewar <dewar@adacore.com> 2014-07-18 Robert Dewar <dewar@adacore.com>
* gnat_rm.texi: Remove mention of obsolete attributes * gnat_rm.texi: Remove mention of obsolete attributes
......
...@@ -101,7 +101,6 @@ package body Einfo is ...@@ -101,7 +101,6 @@ package body Einfo is
-- Entry_Component Node11 -- Entry_Component Node11
-- Enumeration_Pos Uint11 -- Enumeration_Pos Uint11
-- Generic_Homonym Node11 -- Generic_Homonym Node11
-- Last_Aggregate_Assignment Node11
-- Protected_Body_Subprogram Node11 -- Protected_Body_Subprogram Node11
-- Block_Node Node11 -- Block_Node Node11
...@@ -246,6 +245,7 @@ package body Einfo is ...@@ -246,6 +245,7 @@ package body Einfo is
-- Subprograms_For_Type Node29 -- Subprograms_For_Type Node29
-- Corresponding_Equality Node30 -- Corresponding_Equality Node30
-- Last_Aggregate_Assignment Node30
-- Static_Initialization Node30 -- Static_Initialization Node30
-- Thunk_Entity Node31 -- Thunk_Entity Node31
...@@ -2433,8 +2433,8 @@ package body Einfo is ...@@ -2433,8 +2433,8 @@ package body Einfo is
function Last_Aggregate_Assignment (Id : E) return N is function Last_Aggregate_Assignment (Id : E) return N is
begin begin
pragma Assert (Ekind (Id) = E_Variable); pragma Assert (Ekind_In (Id, E_Constant, E_Variable));
return Node11 (Id); return Node30 (Id);
end Last_Aggregate_Assignment; end Last_Aggregate_Assignment;
function Last_Assignment (Id : E) return N is function Last_Assignment (Id : E) return N is
...@@ -5195,8 +5195,8 @@ package body Einfo is ...@@ -5195,8 +5195,8 @@ package body Einfo is
procedure Set_Last_Aggregate_Assignment (Id : E; V : N) is procedure Set_Last_Aggregate_Assignment (Id : E; V : N) is
begin begin
pragma Assert (Ekind (Id) = E_Variable); pragma Assert (Ekind_In (Id, E_Constant, E_Variable));
Set_Node11 (Id, V); Set_Node30 (Id, V);
end Set_Last_Aggregate_Assignment; end Set_Last_Aggregate_Assignment;
procedure Set_Last_Assignment (Id : E; V : N) is procedure Set_Last_Assignment (Id : E; V : N) is
...@@ -8727,9 +8727,6 @@ package body Einfo is ...@@ -8727,9 +8727,6 @@ package body Einfo is
when E_Generic_Package => when E_Generic_Package =>
Write_Str ("Generic_Homonym"); Write_Str ("Generic_Homonym");
when E_Variable =>
Write_Str ("Last_Aggregate_Assignment");
when E_Function | when E_Function |
E_Procedure | E_Procedure |
E_Entry | E_Entry |
...@@ -9526,6 +9523,10 @@ package body Einfo is ...@@ -9526,6 +9523,10 @@ package body Einfo is
when E_Function => when E_Function =>
Write_Str ("Corresponding_Equality"); Write_Str ("Corresponding_Equality");
when E_Constant |
E_Variable =>
Write_Str ("Last_Aggregate_Assignment");
when E_Procedure => when E_Procedure =>
Write_Str ("Static_Initialization"); Write_Str ("Static_Initialization");
......
...@@ -3068,11 +3068,11 @@ package Einfo is ...@@ -3068,11 +3068,11 @@ package Einfo is
-- initialization, it may or may not be set if the type does have -- initialization, it may or may not be set if the type does have
-- preelaborable initialization. -- preelaborable initialization.
-- Last_Aggregate_Assignment (Node11) -- Last_Aggregate_Assignment (Node30)
-- Applies to controlled variables initialized by an aggregate. Points to -- Applies to controlled constants and variables initialized by an
-- the last statement associated with the expansion of the aggregate. The -- aggregate. Points to the last statement associated with the expansion
-- attribute is used by the finalization machinery when marking an object -- of the aggregate. The attribute is used by the finalization machinery
-- as successfully initialized. -- when marking an object as successfully initialized.
-- Last_Assignment (Node26) -- Last_Assignment (Node26)
-- Defined in entities for variables, and OUT or IN OUT formals. Set for -- Defined in entities for variables, and OUT or IN OUT formals. Set for
...@@ -5412,6 +5412,7 @@ package Einfo is ...@@ -5412,6 +5412,7 @@ package Einfo is
-- Related_Type (Node27) (constants only) -- Related_Type (Node27) (constants only)
-- Initialization_Statements (Node28) -- Initialization_Statements (Node28)
-- BIP_Initialization_Call (Node29) -- BIP_Initialization_Call (Node29)
-- Last_Aggregate_Assignment (Node30)
-- Linker_Section_Pragma (Node33) -- Linker_Section_Pragma (Node33)
-- Has_Alignment_Clause (Flag46) -- Has_Alignment_Clause (Flag46)
-- Has_Atomic_Components (Flag86) -- Has_Atomic_Components (Flag86)
...@@ -6102,7 +6103,6 @@ package Einfo is ...@@ -6102,7 +6103,6 @@ package Einfo is
-- Hiding_Loop_Variable (Node8) -- Hiding_Loop_Variable (Node8)
-- Current_Value (Node9) -- Current_Value (Node9)
-- Encapsulating_State (Node10) -- Encapsulating_State (Node10)
-- Last_Aggregate_Assignment (Node11)
-- Esize (Uint12) -- Esize (Uint12)
-- Extra_Accessibility (Node13) -- Extra_Accessibility (Node13)
-- Alignment (Uint14) -- Alignment (Uint14)
...@@ -6121,6 +6121,7 @@ package Einfo is ...@@ -6121,6 +6121,7 @@ package Einfo is
-- Related_Type (Node27) -- Related_Type (Node27)
-- Initialization_Statements (Node28) -- Initialization_Statements (Node28)
-- BIP_Initialization_Call (Node29) -- BIP_Initialization_Call (Node29)
-- Last_Aggregate_Assignment (Node30)
-- Linker_Section_Pragma (Node33) -- Linker_Section_Pragma (Node33)
-- Contract (Node34) -- Contract (Node34)
-- Has_Alignment_Clause (Flag46) -- Has_Alignment_Clause (Flag46)
......
...@@ -75,6 +75,15 @@ package body Exp_Aggr is ...@@ -75,6 +75,15 @@ package body Exp_Aggr is
type Case_Table_Type is array (Nat range <>) of Case_Bounds; type Case_Table_Type is array (Nat range <>) of Case_Bounds;
-- Table type used by Check_Case_Choices procedure -- Table type used by Check_Case_Choices procedure
procedure Collect_Initialization_Statements
(Obj : Entity_Id;
N : Node_Id;
Node_After : Node_Id);
-- If Obj is not frozen, collect actions inserted after N until, but not
-- including, Node_After, for initialization of Obj, and move them to an
-- expression with actions, which becomes the Initialization_Statements for
-- Obj.
function Has_Default_Init_Comps (N : Node_Id) return Boolean; function Has_Default_Init_Comps (N : Node_Id) return Boolean;
-- N is an aggregate (record or array). Checks the presence of default -- N is an aggregate (record or array). Checks the presence of default
-- initialization (<>) in any component (Ada 2005: AI-287). -- initialization (<>) in any component (Ada 2005: AI-287).
...@@ -103,15 +112,6 @@ package body Exp_Aggr is ...@@ -103,15 +112,6 @@ package body Exp_Aggr is
-- statement of variant part will usually be small and probably in near -- statement of variant part will usually be small and probably in near
-- sorted order. -- sorted order.
procedure Collect_Initialization_Statements
(Obj : Entity_Id;
N : Node_Id;
Node_After : Node_Id);
-- If Obj is not frozen, collect actions inserted after N until, but not
-- including, Node_After, for initialization of Obj, and move them to an
-- expression with actions, which becomes the Initialization_Statements for
-- Obj.
------------------------------------------------------ ------------------------------------------------------
-- Local subprograms for Record Aggregate Expansion -- -- Local subprograms for Record Aggregate Expansion --
------------------------------------------------------ ------------------------------------------------------
...@@ -5233,6 +5233,19 @@ package body Exp_Aggr is ...@@ -5233,6 +5233,19 @@ package body Exp_Aggr is
Index => First_Index (Typ), Index => First_Index (Typ),
Into => Target, Into => Target,
Scalar_Comp => Is_Scalar_Type (Ctyp)); Scalar_Comp => Is_Scalar_Type (Ctyp));
-- Save the last assignment statement associated with the aggregate
-- when building a controlled object. This reference is utilized by
-- the finalization machinery when marking an object as successfully
-- initialized.
if Needs_Finalization (Typ)
and then Is_Entity_Name (Target)
and then Present (Entity (Target))
and then Ekind_In (Entity (Target), E_Constant, E_Variable)
then
Set_Last_Aggregate_Assignment (Entity (Target), Last (Aggr_Code));
end if;
end; end;
-- If the aggregate is the expression in a declaration, the expanded -- If the aggregate is the expression in a declaration, the expanded
...@@ -6210,23 +6223,8 @@ package body Exp_Aggr is ...@@ -6210,23 +6223,8 @@ package body Exp_Aggr is
if Is_Record_Type (Etype (N)) then if Is_Record_Type (Etype (N)) then
Aggr_Code := Build_Record_Aggr_Code (N, Typ, Target); Aggr_Code := Build_Record_Aggr_Code (N, Typ, Target);
-- Save the last assignment statement associated with the aggregate
-- when building a controlled object. This reference is utilized by
-- the finalization machinery when marking an object as successfully
-- initialized.
if Needs_Finalization (Typ)
and then Is_Entity_Name (Target)
and then Present (Entity (Target))
and then Ekind (Entity (Target)) = E_Variable
then
Set_Last_Aggregate_Assignment (Entity (Target), Last (Aggr_Code));
end if;
return Aggr_Code;
else pragma Assert (Is_Array_Type (Etype (N))); else pragma Assert (Is_Array_Type (Etype (N)));
return Aggr_Code :=
Build_Array_Aggr_Code Build_Array_Aggr_Code
(N => N, (N => N,
Ctype => Component_Type (Etype (N)), Ctype => Component_Type (Etype (N)),
...@@ -6235,6 +6233,21 @@ package body Exp_Aggr is ...@@ -6235,6 +6233,21 @@ package body Exp_Aggr is
Scalar_Comp => Is_Scalar_Type (Component_Type (Typ)), Scalar_Comp => Is_Scalar_Type (Component_Type (Typ)),
Indexes => No_List); Indexes => No_List);
end if; end if;
-- Save the last assignment statement associated with the aggregate
-- when building a controlled object. This reference is utilized by
-- the finalization machinery when marking an object as successfully
-- initialized.
if Needs_Finalization (Typ)
and then Is_Entity_Name (Target)
and then Present (Entity (Target))
and then Ekind_In (Entity (Target), E_Constant, E_Variable)
then
Set_Last_Aggregate_Assignment (Entity (Target), Last (Aggr_Code));
end if;
return Aggr_Code;
end Late_Expansion; end Late_Expansion;
---------------------------------- ----------------------------------
......
...@@ -162,14 +162,14 @@ package Exp_Ch7 is ...@@ -162,14 +162,14 @@ package Exp_Ch7 is
-- latest extension contains a controlled component. -- latest extension contains a controlled component.
function Make_Adjust_Call function Make_Adjust_Call
(Obj_Ref : Node_Id; (Obj_Ref : Node_Id;
Typ : Entity_Id; Typ : Entity_Id;
For_Parent : Boolean := False) return Node_Id; Skip_Self : Boolean := False) return Node_Id;
-- Create a call to either Adjust or Deep_Adjust depending on the structure -- Create a call to either Adjust or Deep_Adjust depending on the structure
-- of type Typ. Obj_Ref is an expression with no-side effect (not required -- of type Typ. Obj_Ref is an expression with no-side effect (not required
-- to have been previously analyzed) that references the object to be -- to have been previously analyzed) that references the object to be
-- adjusted. Typ is the expected type of Obj_Ref. Flag For_Parent must be -- adjusted. Typ is the expected type of Obj_Ref. When Skip_Self is set,
-- set when an adjustment call is being created for field _parent. -- only the components (if any) are adjusted.
function Make_Attach_Call function Make_Attach_Call
(Obj_Ref : Node_Id; (Obj_Ref : Node_Id;
...@@ -191,15 +191,14 @@ package Exp_Ch7 is ...@@ -191,15 +191,14 @@ package Exp_Ch7 is
-- (System.Finalization_Root.Root_Controlled_Ptr (Obj_Ref)); -- (System.Finalization_Root.Root_Controlled_Ptr (Obj_Ref));
function Make_Final_Call function Make_Final_Call
(Obj_Ref : Node_Id; (Obj_Ref : Node_Id;
Typ : Entity_Id; Typ : Entity_Id;
For_Parent : Boolean := False) return Node_Id; Skip_Self : Boolean := False) return Node_Id;
-- Create a call to either Finalize or Deep_Finalize depending on the -- Create a call to either Finalize or Deep_Finalize depending on the
-- structure of type Typ. Obj_Ref is an expression (with no-side effect and -- structure of type Typ. Obj_Ref is an expression (with no-side effect
-- is not required to have been previously analyzed) that references the -- and is not required to have been previously analyzed) that references
-- object to be finalized. Typ is the expected type of Obj_Ref. Flag For_ -- the object to be finalized. Typ is the expected type of Obj_Ref. When
-- Parent must be set when a finalization call is being created for field -- Skip_Self is set, only the components (if any) are finalized.
-- _parent.
procedure Make_Finalize_Address_Body (Typ : Entity_Id); procedure Make_Finalize_Address_Body (Typ : Entity_Id);
-- Create the body of TSS routine Finalize_Address if Typ is controlled and -- Create the body of TSS routine Finalize_Address if Typ is controlled and
...@@ -300,7 +299,12 @@ package Exp_Ch7 is ...@@ -300,7 +299,12 @@ package Exp_Ch7 is
procedure Store_After_Actions_In_Scope (L : List_Id); procedure Store_After_Actions_In_Scope (L : List_Id);
-- Prepend the list L of actions to the beginning of the after-actions -- Prepend the list L of actions to the beginning of the after-actions
-- stored in the top of the scope stack (also analyzes these actions). -- stored in the top of the scope stack (also analyzes these actions).
-- Why prepend rather than append ??? --
-- Note that we are prepending here rather than appending. This means that
-- if several calls are made to this procedure for the same scope, the
-- actions will be executed in reverse order of the calls (actions for the
-- last call executed first). Within the list L for a single call, the
-- actions are executed in the order in which they appear in this list.
procedure Store_Cleanup_Actions_In_Scope (L : List_Id); procedure Store_Cleanup_Actions_In_Scope (L : List_Id);
-- Prepend the list L of actions to the beginning of the cleanup-actions -- Prepend the list L of actions to the beginning of the cleanup-actions
......
...@@ -2436,10 +2436,11 @@ package body Sem_Ch9 is ...@@ -2436,10 +2436,11 @@ package body Sem_Ch9 is
-- AI05-0225: the target protected object of a requeue must be a -- AI05-0225: the target protected object of a requeue must be a
-- variable. This is a binding interpretation that applies to all -- variable. This is a binding interpretation that applies to all
-- versions of the language. -- versions of the language. Note that the subprogram does not have
-- to be a protected operation: it can be an primitive implemented
-- by entry with a formal that is a protected interface.
if Present (Target_Obj) if Present (Target_Obj)
and then Ekind (Scope (Entry_Id)) in Protected_Kind
and then not Is_Variable (Target_Obj) and then not Is_Variable (Target_Obj)
then then
Error_Msg_N Error_Msg_N
......
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