Commit 22e89283 by Arnaud Charlet

[multiple changes]

2015-05-26  Javier Miranda  <miranda@adacore.com>

	* sem_aggr.adb (Resolve_Aggregate, Resolve_Extension_Aggregate):
	Code cleanup.
	* sem_ch3.adb (Build_Derived_Record_Type,
	Record_Type_Declaration): Code cleanup.
	* sem_ch4.adb (Has_Arbitrary_Evaluation_Order,
	Stop_Subtree_Climbind): Tables which speed up the identification
	of dangerous calls to Ada 2012 functions with writable actuals
	(AI05-0144).
	(Analyze_Arithmetic_Op, Analyze_Call, Analyze_Comparison_Op,
	Analyze_Equality_Op, Analyze_Logical_Op, Analyze_Membership_Op,
	Analyze_Range): Code cleanup.
	(Is_Arbitrary_Evaluation_Order_Construct): Removed.
	(Check_Writable_Actuals): Code cleanup using the added tables.
	* sem_util.adb (Check_Function_Writable_Actuals): Return
	immediately if the node does not have the flag Check_Actuals
	set to True.

2015-05-26  Eric Botcazou  <ebotcazou@adacore.com>

	* exp_ch6.adb (Add_Call_By_Copy_Code): Remove restrictive
	condition in the detection of the effects of Remove_Side_Effects.
	* exp_util.ads (Remove_Side_Effects): Add general and historical note.
	* exp_util.adb (Is_Name_Reference): New predicate.
	(Remove_Side_Effects): Use it in lieu of Is_Object_Reference
	in order to decide whether to use the renaming to capture the
	side effects of the subexpression.
	(Side_Effect_Free): Remove obsolete test.

From-SVN: r223668
parent c8593453
2015-05-26 Javier Miranda <miranda@adacore.com>
* sem_aggr.adb (Resolve_Aggregate, Resolve_Extension_Aggregate):
Code cleanup.
* sem_ch3.adb (Build_Derived_Record_Type,
Record_Type_Declaration): Code cleanup.
* sem_ch4.adb (Has_Arbitrary_Evaluation_Order,
Stop_Subtree_Climbind): Tables which speed up the identification
of dangerous calls to Ada 2012 functions with writable actuals
(AI05-0144).
(Analyze_Arithmetic_Op, Analyze_Call, Analyze_Comparison_Op,
Analyze_Equality_Op, Analyze_Logical_Op, Analyze_Membership_Op,
Analyze_Range): Code cleanup.
(Is_Arbitrary_Evaluation_Order_Construct): Removed.
(Check_Writable_Actuals): Code cleanup using the added tables.
* sem_util.adb (Check_Function_Writable_Actuals): Return
immediately if the node does not have the flag Check_Actuals
set to True.
2015-05-26 Eric Botcazou <ebotcazou@adacore.com>
* exp_ch6.adb (Add_Call_By_Copy_Code): Remove restrictive
condition in the detection of the effects of Remove_Side_Effects.
* exp_util.ads (Remove_Side_Effects): Add general and historical note.
* exp_util.adb (Is_Name_Reference): New predicate.
(Remove_Side_Effects): Use it in lieu of Is_Object_Reference
in order to decide whether to use the renaming to capture the
side effects of the subexpression.
(Side_Effect_Free): Remove obsolete test.
2015-05-26 Robert Dewar <dewar@adacore.com>
* aspects.ads, aspects.adb: Add aspect Disable_Controlled.
......
......@@ -1257,7 +1257,6 @@ package body Exp_Ch6 is
begin
if Is_Renaming_Of_Object (Var)
and then Nkind (Renamed_Object (Var)) = N_Selected_Component
and then Is_Entity_Name (Prefix (Renamed_Object (Var)))
and then Nkind (Original_Node (Prefix (Renamed_Object (Var))))
= N_Indexed_Component
and then
......
......@@ -872,8 +872,8 @@ package Exp_Util is
-- call and is analyzed and resolved on return. Name_Req may only be set to
-- True if Exp has the form of a name, and the effect is to guarantee that
-- any replacement maintains the form of name. If Renaming_Req is set to
-- TRUE, the routine produces an object renaming reclaration capturing the
-- expression. If Variable_Ref is set to TRUE, a variable is considered as
-- True, the routine produces an object renaming reclaration capturing the
-- expression. If Variable_Ref is set to True, a variable is considered as
-- side effect (used in implementing Force_Evaluation). Note: after call to
-- Remove_Side_Effects, it is safe to call New_Copy_Tree to obtain a copy
-- of the resulting expression.
......@@ -885,6 +885,26 @@ package Exp_Util is
-- Chars (Related_Id)_FIRST/_LAST. If Related_Id is set, then exactly one
-- of the Is_xxx_Bound flags must be set. For use of these parameters see
-- the warning in the body of Sem_Ch3.Process_Range_Expr_In_Decl.
--
-- The side effects are captured using one of the following methods:
--
-- 1) a constant initialized with the value of the subexpression
-- 2) a renaming of the subexpression
-- 3) a reference to the subexpression
--
-- For elementary types, methods 1) and 2) are used; for composite types,
-- methods 2) and 3) are used. The renaming (method 2) is used only when
-- the subexpression denotes a name, so that it can be elaborated by gigi
-- without evaluating the subexpression.
--
-- Historical note: the reference (method 3) used to be the common fallback
-- method but it gives rise to aliasing issues if the subexpression denotes
-- a name that is not aliased, since it is equivalent to taking the address
-- in this case. The renaming (method 2) used to be applied to any objects
-- in the RM sense, that is to say to the cases where a renaming is legal
-- in Ada. But for some of these cases, most notably functions calls, the
-- renaming cannot be elaborated without evaluating the subexpression, so
-- gigi would resort to method 1) or 3) under the hood for them.
function Represented_As_Scalar (T : Entity_Id) return Boolean;
-- Returns True iff the implementation of this type in code generation
......
......@@ -1161,9 +1161,7 @@ package body Sem_Aggr is
Set_Analyzed (N);
end if;
if Check_Actuals (N) then
Check_Function_Writable_Actuals (N);
end if;
Check_Function_Writable_Actuals (N);
end Resolve_Aggregate;
-----------------------------
......@@ -2906,9 +2904,7 @@ package body Sem_Aggr is
Error_Msg_N ("no unique type for this aggregate", A);
end if;
if Check_Actuals (N) then
Check_Function_Writable_Actuals (N);
end if;
Check_Function_Writable_Actuals (N);
end Resolve_Extension_Aggregate;
------------------------------
......
......@@ -8955,9 +8955,7 @@ package body Sem_Ch3 is
(Class_Wide_Type (Derived_Type), Last_Entity (Derived_Type));
end if;
if Check_Actuals (N) then
Check_Function_Writable_Actuals (N);
end if;
Check_Function_Writable_Actuals (N);
end Build_Derived_Record_Type;
------------------------
......@@ -21122,9 +21120,7 @@ package body Sem_Ch3 is
Derive_Progenitor_Subprograms (T, T);
end if;
if Check_Actuals (N) then
Check_Function_Writable_Actuals (N);
end if;
Check_Function_Writable_Actuals (N);
end Record_Type_Declaration;
----------------------------
......
......@@ -2324,11 +2324,12 @@ package body Sem_Util is
-- Start of processing for Check_Function_Writable_Actuals
begin
-- The check only applies to Ada 2012 code, and only to constructs that
-- have multiple constituents whose order of evaluation is not specified
-- by the language.
-- The check only applies to Ada 2012 code on which Check_Actuals has
-- been set, and only to constructs that have multiple constituents
-- whose order of evaluation is not specified by the language.
if Ada_Version < Ada_2012
or else not Check_Actuals (N)
or else (not (Nkind (N) in N_Op)
and then not (Nkind (N) in N_Membership_Test)
and then not Nkind_In (N, N_Range,
......
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