Commit b4213ffd by Arnaud Charlet

[multiple changes]

2016-04-19  Hristian Kirtchev  <kirtchev@adacore.com>

	* checks.adb, sem_util.adb, sem_res.adb, sem_attr.adb: Minor
	reformatting.

2016-04-19  Ed Schonberg  <schonberg@adacore.com>

	* freeze.adb (Freeze_Profile): Refine predicate that checks
	whether a function that returns a limited view is declared in
	another unit and cannot be frozen at this point.

2016-04-19  Ed Schonberg  <schonberg@adacore.com>

	* exp_aggr.adb (Component_Count): Handle properly superflat
	arrays, i.e. empty arrays where Hi < Lo - 1, to ensure that the
	return value of the function is Natural, rather than leaving
	the handling of such arrays to the caller of this function.

From-SVN: r235200
parent b3143037
2016-04-19 Hristian Kirtchev <kirtchev@adacore.com>
* checks.adb, sem_util.adb, sem_res.adb, sem_attr.adb: Minor
reformatting.
2016-04-19 Ed Schonberg <schonberg@adacore.com>
* freeze.adb (Freeze_Profile): Refine predicate that checks
whether a function that returns a limited view is declared in
another unit and cannot be frozen at this point.
2016-04-19 Ed Schonberg <schonberg@adacore.com>
* exp_aggr.adb (Component_Count): Handle properly superflat
arrays, i.e. empty arrays where Hi < Lo - 1, to ensure that the
return value of the function is Natural, rather than leaving
the handling of such arrays to the caller of this function.
2016-04-19 Arnaud Charlet <charlet@adacore.com> 2016-04-19 Arnaud Charlet <charlet@adacore.com>
* sem_prag.adb, sem_attr.adb, par-prag.adb, exp_aggr.adb, sem_type.adb * sem_prag.adb, sem_attr.adb, par-prag.adb, exp_aggr.adb, sem_type.adb
......
...@@ -2354,11 +2354,13 @@ package body Checks is ...@@ -2354,11 +2354,13 @@ package body Checks is
-- Local variables -- Local variables
Actual_1 : Node_Id; Actual_1 : Node_Id;
Actual_2 : Node_Id; Actual_2 : Node_Id;
Check : Node_Id; Check : Node_Id;
Formal_1 : Entity_Id; Formal_1 : Entity_Id;
Formal_2 : Entity_Id; Formal_2 : Entity_Id;
Orig_Act_1 : Node_Id;
Orig_Act_2 : Node_Id;
-- Start of processing for Apply_Parameter_Aliasing_Checks -- Start of processing for Apply_Parameter_Aliasing_Checks
...@@ -2368,6 +2370,7 @@ package body Checks is ...@@ -2368,6 +2370,7 @@ package body Checks is
Actual_1 := First_Actual (Call); Actual_1 := First_Actual (Call);
Formal_1 := First_Formal (Subp); Formal_1 := First_Formal (Subp);
while Present (Actual_1) and then Present (Formal_1) loop while Present (Actual_1) and then Present (Formal_1) loop
Orig_Act_1 := Original_Actual (Actual_1);
-- Ensure that the actual is an object that is not passed by value. -- Ensure that the actual is an object that is not passed by value.
-- Elementary types are always passed by value, therefore actuals of -- Elementary types are always passed by value, therefore actuals of
...@@ -2378,30 +2381,27 @@ package body Checks is ...@@ -2378,30 +2381,27 @@ package body Checks is
-- will be done in place and a subsequent read will always see the -- will be done in place and a subsequent read will always see the
-- correct value, see RM 6.2 (12/3). -- correct value, see RM 6.2 (12/3).
if Nkind (Original_Actual (Actual_1)) = N_Aggregate if Nkind (Orig_Act_1) = N_Aggregate
or else or else (Nkind (Orig_Act_1) = N_Qualified_Expression
(Nkind (Original_Actual (Actual_1)) = N_Qualified_Expression and then Nkind (Expression (Orig_Act_1)) = N_Aggregate)
and then Nkind (Expression (Original_Actual (Actual_1))) =
N_Aggregate)
then then
null; null;
elsif Is_Object_Reference (Original_Actual (Actual_1)) elsif Is_Object_Reference (Orig_Act_1)
and then not Is_Elementary_Type (Etype (Original_Actual (Actual_1))) and then not Is_Elementary_Type (Etype (Orig_Act_1))
and then and then not Is_By_Reference_Type (Etype (Orig_Act_1))
not Is_By_Reference_Type (Etype (Original_Actual (Actual_1)))
then then
Actual_2 := Next_Actual (Actual_1); Actual_2 := Next_Actual (Actual_1);
Formal_2 := Next_Formal (Formal_1); Formal_2 := Next_Formal (Formal_1);
while Present (Actual_2) and then Present (Formal_2) loop while Present (Actual_2) and then Present (Formal_2) loop
Orig_Act_2 := Original_Actual (Actual_2);
-- The other actual we are testing against must also denote -- The other actual we are testing against must also denote
-- a non pass-by-value object. Generate the check only when -- a non pass-by-value object. Generate the check only when
-- the mode of the two formals may lead to aliasing. -- the mode of the two formals may lead to aliasing.
if Is_Object_Reference (Original_Actual (Actual_2)) if Is_Object_Reference (Orig_Act_2)
and then not and then not Is_Elementary_Type (Etype (Orig_Act_2))
Is_Elementary_Type (Etype (Original_Actual (Actual_2)))
and then May_Cause_Aliasing (Formal_1, Formal_2) and then May_Cause_Aliasing (Formal_1, Formal_2)
then then
Overlap_Check Overlap_Check
......
...@@ -354,10 +354,16 @@ package body Exp_Aggr is ...@@ -354,10 +354,16 @@ package body Exp_Aggr is
Siz : constant Nat := Component_Count (Component_Type (T)); Siz : constant Nat := Component_Count (Component_Type (T));
begin begin
-- Check for superflat arrays, i.e. arrays with such bounds
-- as 4 .. 2, to insure that this function never returns a
-- meaningless negative value.
if not Compile_Time_Known_Value (Lo) if not Compile_Time_Known_Value (Lo)
or else not Compile_Time_Known_Value (Hi) or else not Compile_Time_Known_Value (Hi)
or else Expr_Value (Hi) < Expr_Value (Lo)
then then
return 0; return 0;
else else
return return
Siz * UI_To_Int (Expr_Value (Hi) - Expr_Value (Lo) + 1); Siz * UI_To_Int (Expr_Value (Hi) - Expr_Value (Lo) + 1);
......
...@@ -3288,12 +3288,14 @@ package body Freeze is ...@@ -3288,12 +3288,14 @@ package body Freeze is
if Ekind (E) = E_Function then if Ekind (E) = E_Function then
-- Check whether function is declared elsewhere. -- Check whether function is declared elsewhere. Previous code
-- used Get_Source_Unit on both arguments, but the values are
-- equal in the case of a parent and a child unit.
-- Confusion with subunits in code ????
Late_Freezing := Late_Freezing :=
Get_Source_Unit (E) /= Get_Source_Unit (N) not In_Same_Extended_Unit (E, N)
and then Returns_Limited_View (E) and then Returns_Limited_View (E);
and then not In_Open_Scopes (Scope (E));
-- Freeze return type -- Freeze return type
......
...@@ -10094,11 +10094,10 @@ package body Sem_Attr is ...@@ -10094,11 +10094,10 @@ package body Sem_Attr is
Freeze_Before (N, Entity (P)); Freeze_Before (N, Entity (P));
end if; end if;
-- If it is a type, there is nothing to resolve. -- If it is a type, there is nothing to resolve. If it is an
-- If it is an object, complete its resolution. -- object, complete its resolution.
elsif Is_Overloadable (Entity (P)) then elsif Is_Overloadable (Entity (P)) then
if not In_Spec_Expression then if not In_Spec_Expression then
Freeze_Before (N, Entity (P)); Freeze_Before (N, Entity (P));
end if; end if;
......
...@@ -6963,8 +6963,8 @@ package body Sem_Res is ...@@ -6963,8 +6963,8 @@ package body Sem_Res is
then then
null; null;
else else
Error_Msg_N ( Error_Msg_N
"deferred constant is frozen before completion", N); ("deferred constant is frozen before completion", N);
end if; end if;
end if; end if;
......
...@@ -13103,9 +13103,9 @@ package body Sem_Util is ...@@ -13103,9 +13103,9 @@ package body Sem_Util is
Par := Nod; Par := Nod;
while Present (Par) loop while Present (Par) loop
if Nkind_In (Par, N_Function_Call, if Nkind_In (Par, N_Entry_Call_Statement,
N_Procedure_Call_Statement, N_Function_Call,
N_Entry_Call_Statement) N_Procedure_Call_Statement)
then then
return True; return True;
...@@ -15978,22 +15978,20 @@ package body Sem_Util is ...@@ -15978,22 +15978,20 @@ package body Sem_Util is
if New_Sloc /= No_Location then if New_Sloc /= No_Location then
Set_Sloc (New_Node, New_Sloc); Set_Sloc (New_Node, New_Sloc);
-- If we adjust the Sloc, then we are essentially making -- If we adjust the Sloc, then we are essentially making a
-- a completely new node, so the Comes_From_Source flag -- completely new node, so the Comes_From_Source flag should
-- should be reset to the proper default value. -- be reset to the proper default value.
Set_Comes_From_Source (New_Node,
Default_Node.Comes_From_Source);
Set_Comes_From_Source
(New_Node, Default_Node.Comes_From_Source);
end if; end if;
-- If the node is call and has named associations, -- If the node is a call and has named associations, set the
-- set the corresponding links in the copy. -- corresponding links in the copy.
if (Nkind (Old_Node) = N_Function_Call if Nkind_In (Old_Node, N_Entry_Call_Statement,
or else Nkind (Old_Node) = N_Entry_Call_Statement N_Function_Call,
or else N_Procedure_Call_Statement)
Nkind (Old_Node) = N_Procedure_Call_Statement)
and then Present (First_Named_Actual (Old_Node)) and then Present (First_Named_Actual (Old_Node))
then then
Adjust_Named_Associations (Old_Node, New_Node); Adjust_Named_Associations (Old_Node, New_Node);
......
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