Commit d976bf74 by Arnaud Charlet

[multiple changes]

2012-10-01  Hristian Kirtchev  <kirtchev@adacore.com>

	* sem_ch3.adb (Analyze_Declarations): Remove the specialized
	code which prevents freezing when the declarative list contains
	a _postconditions body. This is no longer needed because the
	body is now inserted at the end of the declarations.
	* sem_ch6.adb (Insert_After_Last_Declaration): New routine.
	(Insert_Before_First_Source_Declaration): Removed.
	(Process_PPCs): Insert the _postconditions body at the end of
	the declarative list to prevent premature freezing of types that
	appear in the declarations.

2012-10-01  Robert Dewar  <dewar@adacore.com>

	* sem_aggr.adb, sem_dim.adb: Minor reformatting.

From-SVN: r191911
parent 0929eaeb
2012-10-01 Hristian Kirtchev <kirtchev@adacore.com>
* sem_ch3.adb (Analyze_Declarations): Remove the specialized
code which prevents freezing when the declarative list contains
a _postconditions body. This is no longer needed because the
body is now inserted at the end of the declarations.
* sem_ch6.adb (Insert_After_Last_Declaration): New routine.
(Insert_Before_First_Source_Declaration): Removed.
(Process_PPCs): Insert the _postconditions body at the end of
the declarative list to prevent premature freezing of types that
appear in the declarations.
2012-10-01 Robert Dewar <dewar@adacore.com>
* sem_aggr.adb, sem_dim.adb: Minor reformatting.
2012-10-01 Ed Schonberg <schonberg@adacore.com> 2012-10-01 Ed Schonberg <schonberg@adacore.com>
* sem_prag.adb (Process_Convention, Process_Import_Or_Interface): * sem_prag.adb (Process_Convention, Process_Import_Or_Interface):
......
...@@ -2550,7 +2550,7 @@ package body Sem_Aggr is ...@@ -2550,7 +2550,7 @@ package body Sem_Aggr is
Duplicate_Subexpr (High_Bound (Aggregate_Bounds (N)))); Duplicate_Subexpr (High_Bound (Aggregate_Bounds (N))));
end if; end if;
-- Check the dimensions of each component in the array aggregate. -- Check the dimensions of each component in the array aggregate
Analyze_Dimension_Array_Aggregate (N, Component_Typ); Analyze_Dimension_Array_Aggregate (N, Component_Typ);
...@@ -3392,6 +3392,7 @@ package body Sem_Aggr is ...@@ -3392,6 +3392,7 @@ package body Sem_Aggr is
-- propagate here the dimensions form Expr to New_Expr. -- propagate here the dimensions form Expr to New_Expr.
Move_Dimensions (Expr, New_Expr); Move_Dimensions (Expr, New_Expr);
else else
New_Expr := Expr; New_Expr := Expr;
end if; end if;
...@@ -4504,7 +4505,7 @@ package body Sem_Aggr is ...@@ -4504,7 +4505,7 @@ package body Sem_Aggr is
Rewrite (N, New_Aggregate); Rewrite (N, New_Aggregate);
end Step_8; end Step_8;
-- Check the dimensions of the components in the record aggregate. -- Check the dimensions of the components in the record aggregate
Analyze_Dimension_Extension_Or_Record_Aggregate (N); Analyze_Dimension_Extension_Or_Record_Aggregate (N);
end Resolve_Record_Aggregate; end Resolve_Record_Aggregate;
......
...@@ -2152,9 +2152,7 @@ package body Sem_Ch3 is ...@@ -2152,9 +2152,7 @@ package body Sem_Ch3 is
-- explicitly checked that all required types are properly frozen, -- explicitly checked that all required types are properly frozen,
-- and we do not cause general freezing here. This special circuit -- and we do not cause general freezing here. This special circuit
-- is used when the encountered body is marked as having already -- is used when the encountered body is marked as having already
-- been analyzed (although we must take into account the special -- been analyzed.
-- case of the internally generated subprogram _postconditions,
-- may not have been analyzed yet)
-- In all other cases (bodies that come from source, and expander -- In all other cases (bodies that come from source, and expander
-- generated bodies that have not been analyzed yet), freeze all -- generated bodies that have not been analyzed yet), freeze all
...@@ -2170,11 +2168,6 @@ package body Sem_Ch3 is ...@@ -2170,11 +2168,6 @@ package body Sem_Ch3 is
N_Task_Body) N_Task_Body)
or else or else
Nkind (Next_Node) in N_Body_Stub) Nkind (Next_Node) in N_Body_Stub)
and then not
(Ada_Version = Ada_2012
and then Nkind (Next_Node) = N_Subprogram_Body
and then Chars (Defining_Entity (Next_Node))
= Name_uPostconditions)
then then
Adjust_D; Adjust_D;
Freeze_All (Freeze_From, D); Freeze_All (Freeze_From, D);
......
...@@ -11091,8 +11091,8 @@ package body Sem_Ch6 is ...@@ -11091,8 +11091,8 @@ package body Sem_Ch6 is
-- references to parameters of the inherited subprogram to point to the -- references to parameters of the inherited subprogram to point to the
-- corresponding parameters of the current subprogram. -- corresponding parameters of the current subprogram.
procedure Insert_Before_First_Source_Declaration (Nod : Node_Id); procedure Insert_After_Last_Declaration (Nod : Node_Id);
-- Insert node Nod before the first source declaration of the context -- Insert node Nod after the last declaration of the context
function Invariants_Or_Predicates_Present return Boolean; function Invariants_Or_Predicates_Present return Boolean;
-- Determines if any invariants or predicates are present for any OUT -- Determines if any invariants or predicates are present for any OUT
...@@ -11285,35 +11285,20 @@ package body Sem_Ch6 is ...@@ -11285,35 +11285,20 @@ package body Sem_Ch6 is
return CP; return CP;
end Grab_PPC; end Grab_PPC;
-------------------------------------------- -----------------------------------
-- Insert_Before_First_Source_Declaration -- -- Insert_After_Last_Declaration --
-------------------------------------------- -----------------------------------
procedure Insert_Before_First_Source_Declaration (Nod : Node_Id) is procedure Insert_After_Last_Declaration (Nod : Node_Id) is
Decls : constant List_Id := Declarations (N); Decls : constant List_Id := Declarations (N);
Decl : Node_Id;
begin begin
if No (Decls) then if No (Decls) then
Set_Declarations (N, New_List (Nod)); Set_Declarations (N, New_List (Nod));
else else
Decl := First (Decls); Append_To (Decls, Nod);
while Present (Decl) loop
if Comes_From_Source (Decl) then
exit;
end if;
Next (Decl);
end loop;
if No (Decl) then
Append_To (Decls, Nod);
else
Insert_Before (Decl, Nod);
end if;
end if; end if;
end Insert_Before_First_Source_Declaration; end Insert_After_Last_Declaration;
-------------------------------------- --------------------------------------
-- Invariants_Or_Predicates_Present -- -- Invariants_Or_Predicates_Present --
...@@ -11797,12 +11782,26 @@ package body Sem_Ch6 is ...@@ -11797,12 +11782,26 @@ package body Sem_Ch6 is
-- The entity for the _Postconditions procedure -- The entity for the _Postconditions procedure
begin begin
-- Insert the corresponding body of a post condition pragma before -- Insert the corresponding body of a post condition pragma after
-- the first source declaration of the context. This ensures that -- the last declaration of the context. This ensures that the body
-- any [sub]types generated in relation to the formals of the -- will not cause any premature freezing as it may mention types:
-- subprogram are still visible in the _postcondition body.
-- procedure Proc (Obj : Array_Typ) is
Insert_Before_First_Source_Declaration ( -- procedure _postconditions is
-- begin
-- ... Obj ...
-- end _postconditions;
-- subtype T is Array_Typ (Obj'First (1) .. Obj'Last (1));
-- begin
-- In the example above, Obj is of type T but the incorrect
-- placement of _postconditions will cause a crash in gigi due to
-- an out of order reference. The body of _postconditions must be
-- placed after the declaration of Temp to preserve correct
-- visibility.
Insert_After_Last_Declaration (
Make_Subprogram_Body (Loc, Make_Subprogram_Body (Loc,
Specification => Specification =>
Make_Procedure_Specification (Loc, Make_Procedure_Specification (Loc,
......
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