Commit 0592046e by Arnaud Charlet

[multiple changes]

2010-10-26  Javier Miranda  <miranda@adacore.com>

	* sem_prag.adb (Process_Import_Or_Interface): Skip primitives of
	interface types when processing all the entities in the homonym chain
	that are declared in the same declarative part.

2010-10-26  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch3.adb (Process_Range_In_Decl): If the range is part of a
	quantified expression, the insertion point for range checks will be
	arbitrarily far in the tree.
	* sem_ch5.adb (One_Bound): Use Insert_Actions for the declaration of
	the temporary that holds the value of the bounds.
	* sem_res.adb (Resolve_Quantified_Expressions): Disable expansion of
	condition until the full expression is expanded.

From-SVN: r165957
parent 880dabb5
2010-10-26 Javier Miranda <miranda@adacore.com>
* sem_prag.adb (Process_Import_Or_Interface): Skip primitives of
interface types when processing all the entities in the homonym chain
that are declared in the same declarative part.
2010-10-26 Ed Schonberg <schonberg@adacore.com>
* sem_ch3.adb (Process_Range_In_Decl): If the range is part of a
quantified expression, the insertion point for range checks will be
arbitrarily far in the tree.
* sem_ch5.adb (One_Bound): Use Insert_Actions for the declaration of
the temporary that holds the value of the bounds.
* sem_res.adb (Resolve_Quantified_Expressions): Disable expansion of
condition until the full expression is expanded.
2010-10-26 Robert Dewar <dewar@adacore.com> 2010-10-26 Robert Dewar <dewar@adacore.com>
* opt.ads: Comment fix. * opt.ads: Comment fix.
......
...@@ -17629,7 +17629,7 @@ package body Sem_Ch3 is ...@@ -17629,7 +17629,7 @@ package body Sem_Ch3 is
is is
Lo, Hi : Node_Id; Lo, Hi : Node_Id;
R_Checks : Check_Result; R_Checks : Check_Result;
Type_Decl : Node_Id; Insert_Node : Node_Id;
Def_Id : Entity_Id; Def_Id : Entity_Id;
begin begin
...@@ -17738,32 +17738,43 @@ package body Sem_Ch3 is ...@@ -17738,32 +17738,43 @@ package body Sem_Ch3 is
if not R_Check_Off then if not R_Check_Off then
R_Checks := Get_Range_Checks (R, T); R_Checks := Get_Range_Checks (R, T);
-- Look up tree to find an appropriate insertion point. -- Look up tree to find an appropriate insertion point. We
-- This seems really junk code, and very brittle, couldn't -- can't just use insert_actions because later processing
-- we just use an insert actions call of some kind ??? -- depends on the insertion node. Prior to Ada2012 the
-- insertion point could only be a declaration or a loop, but
-- quantified expressions can appear within any context in an
-- expression, and the insertion point can be any statement,
-- pragma, or declaration.
Type_Decl := Parent (R); Insert_Node := Parent (R);
while Present (Type_Decl) and then not while Present (Insert_Node) loop
(Nkind_In (Type_Decl, N_Full_Type_Declaration, exit when
N_Subtype_Declaration, Nkind (Insert_Node) in N_Declaration
N_Loop_Statement, and then
N_Task_Type_Declaration) not Nkind_In
or else (Insert_Node, N_Component_Declaration,
Nkind_In (Type_Decl, N_Single_Task_Declaration, N_Loop_Parameter_Specification,
N_Protected_Type_Declaration, N_Function_Specification,
N_Single_Protected_Declaration)) N_Procedure_Specification);
loop
Type_Decl := Parent (Type_Decl); exit when Nkind (Insert_Node) in N_Later_Decl_Item
or else Nkind (Insert_Node) in
N_Statement_Other_Than_Procedure_Call
or else Nkind_In (Insert_Node, N_Procedure_Call_Statement,
N_Pragma);
Insert_Node := Parent (Insert_Node);
end loop; end loop;
-- Why would Type_Decl not be present??? Without this test, -- Why would Type_Decl not be present??? Without this test,
-- short regression tests fail. -- short regression tests fail.
if Present (Type_Decl) then if Present (Insert_Node) then
-- Case of loop statement (more comments ???) -- Case of loop statement. Verify that the range is part
-- of the subtype indication of the iteration scheme.
if Nkind (Type_Decl) = N_Loop_Statement then if Nkind (Insert_Node) = N_Loop_Statement then
declare declare
Indic : Node_Id; Indic : Node_Id;
...@@ -17780,18 +17791,20 @@ package body Sem_Ch3 is ...@@ -17780,18 +17791,20 @@ package body Sem_Ch3 is
Insert_Range_Checks Insert_Range_Checks
(R_Checks, (R_Checks,
Type_Decl, Insert_Node,
Def_Id, Def_Id,
Sloc (Type_Decl), Sloc (Insert_Node),
R, R,
Do_Before => True); Do_Before => True);
end if; end if;
end; end;
-- All other cases (more comments ???) -- Insertion before a declaration. If the declaration
-- includes discriminants, the list of applicable checks
-- is given by the caller.
else elsif Nkind (Insert_Node) in N_Declaration then
Def_Id := Defining_Identifier (Type_Decl); Def_Id := Defining_Identifier (Insert_Node);
if (Ekind (Def_Id) = E_Record_Type if (Ekind (Def_Id) = E_Record_Type
and then Depends_On_Discriminant (R)) and then Depends_On_Discriminant (R))
...@@ -17800,18 +17813,29 @@ package body Sem_Ch3 is ...@@ -17800,18 +17813,29 @@ package body Sem_Ch3 is
and then Has_Discriminants (Def_Id)) and then Has_Discriminants (Def_Id))
then then
Append_Range_Checks Append_Range_Checks
(R_Checks, Check_List, Def_Id, Sloc (Type_Decl), R); (R_Checks,
Check_List, Def_Id, Sloc (Insert_Node), R);
else else
Insert_Range_Checks Insert_Range_Checks
(R_Checks, Type_Decl, Def_Id, Sloc (Type_Decl), R); (R_Checks,
Insert_Node, Def_Id, Sloc (Insert_Node), R);
end if; end if;
-- Insertion before a statement. Range appears in the
-- context of a quantified expression. Insertion will
-- take place when expression is expanded.
else
null;
end if; end if;
end if; end if;
end if; end if;
end if; end if;
-- Case of other than an explicit N_Range node
elsif Expander_Active then elsif Expander_Active then
Get_Index_Bounds (R, Lo, Hi); Get_Index_Bounds (R, Lo, Hi);
Force_Evaluation (Lo); Force_Evaluation (Lo);
......
...@@ -1538,8 +1538,11 @@ package body Sem_Ch5 is ...@@ -1538,8 +1538,11 @@ package body Sem_Ch5 is
Object_Definition => New_Occurrence_Of (Typ, Loc), Object_Definition => New_Occurrence_Of (Typ, Loc),
Expression => Relocate_Node (Original_Bound)); Expression => Relocate_Node (Original_Bound));
Insert_Before (Parent (N), Decl); -- Insert declaration at proper place. If loop comes from an
Analyze (Decl); -- enclosing quantified expression, the insertion point is
-- arbitrarily far up in the tree.
Insert_Action (Parent (N), Decl);
Rewrite (Original_Bound, New_Occurrence_Of (Id, Loc)); Rewrite (Original_Bound, New_Occurrence_Of (Id, Loc));
return Expression (Decl); return Expression (Decl);
end if; end if;
......
...@@ -3928,6 +3928,14 @@ package body Sem_Prag is ...@@ -3928,6 +3928,14 @@ package body Sem_Prag is
then then
null; null;
-- The pragma does not apply to primitives of interfaces
elsif Is_Dispatching_Operation (Def_Id)
and then Present (Find_Dispatching_Type (Def_Id))
and then Is_Interface (Find_Dispatching_Type (Def_Id))
then
null;
-- Verify that the homonym is in the same declarative part (not -- Verify that the homonym is in the same declarative part (not
-- just the same scope). -- just the same scope).
...@@ -4047,10 +4055,10 @@ package body Sem_Prag is ...@@ -4047,10 +4055,10 @@ package body Sem_Prag is
and then C = Convention_CPP and then C = Convention_CPP
then then
-- Types treated as CPP classes are treated as limited, but we -- Types treated as CPP classes are treated as limited, but we
-- don't require them to be declared this way. A warning is -- don't require them to be declared this way. A warning is issued
-- issued to encourage the user to declare them as limited. -- to encourage the user to declare them as limited. This is not
-- This is not an error, for compatibility reasons, because -- an error, for compatibility reasons, because these types have
-- these types have been supported this way for some time. -- been supported this way for some time.
if not Is_Limited_Type (Def_Id) then if not Is_Limited_Type (Def_Id) then
Error_Msg_N Error_Msg_N
......
...@@ -7809,9 +7809,13 @@ package body Sem_Res is ...@@ -7809,9 +7809,13 @@ package body Sem_Res is
procedure Resolve_Quantified_Expression (N : Node_Id; Typ : Entity_Id) is procedure Resolve_Quantified_Expression (N : Node_Id; Typ : Entity_Id) is
begin begin
-- The loop structure is already resolved during its analysis, only the -- The loop structure is already resolved during its analysis, only the
-- resolution of the condition needs to be done. -- resolution of the condition needs to be done. Expansion is disabled
-- so that checks and other generated code are inserted in the tree
-- after expression has been rewritten as a loop.
Expander_Mode_Save_And_Set (False);
Resolve (Condition (N), Typ); Resolve (Condition (N), Typ);
Expander_Mode_Restore;
end Resolve_Quantified_Expression; end Resolve_Quantified_Expression;
------------------- -------------------
......
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