Commit dd4e47ab by Arnaud Charlet

[multiple changes]

2013-04-23  Ed Schonberg  <schonberg@adacore.com>

	* sem_util.ads, sem_util.adb: Code cleanup for Is_Expression_Function
	(can apply to any scope entity).
	* sem_res.adb (Resolve_Call):  If the call is within another
	expression function it does not constitute a freeze point.

2013-04-23  Yannick Moy  <moy@adacore.com>

	* exp_ch6.adb (Expand_Actuals): Test that Subp
	is overloadable before testing if it's an inherited operation.

From-SVN: r198181
parent 872c2f37
2013-04-23 Ed Schonberg <schonberg@adacore.com>
* sem_util.ads, sem_util.adb: Code cleanup for Is_Expression_Function
(can apply to any scope entity).
* sem_res.adb (Resolve_Call): If the call is within another
expression function it does not constitute a freeze point.
2013-04-23 Yannick Moy <moy@adacore.com>
* exp_ch6.adb (Expand_Actuals): Test that Subp
is overloadable before testing if it's an inherited operation.
2013-04-23 Robert Dewar <dewar@adacore.com>
* a-envvar.adb, a-envvar.ads, exp_util.adb, sem_ch12.adb: Minor
......
......@@ -1719,6 +1719,11 @@ package body Exp_Ch6 is
-- subtype is elaborated before the body of the subprogram, but
-- this is harder to verify, and there may be a redundant check.
-- Note also that Subp may be either a subprogram entity for
-- direct calls, or a type entity for indirect calls, hence the
-- test that Is_Overloadable returns True before testing whether
-- Subp is an inherited operation.
if (Present (Find_Aspect (E_Actual, Aspect_Predicate))
or else
Present (Find_Aspect (E_Actual, Aspect_Dynamic_Predicate))
......@@ -1727,6 +1732,7 @@ package body Exp_Ch6 is
and then not Is_Init_Proc (Subp)
then
if (Is_Derived_Type (E_Actual)
and then Is_Overloadable (Subp)
and then Is_Inherited_Operation_For_Type (Subp, E_Actual))
or else Is_Entity_Name (Actual)
then
......
......@@ -5386,12 +5386,14 @@ package body Sem_Res is
-- In Ada 2012, expression functions may be called within pre/post
-- conditions of subsequent functions or expression functions. Such
-- calls do not freeze when they appear within generated bodies, which
-- would place the freeze node in the wrong scope. An expression
-- function is frozen in the usual fashion, by the appearance of a real
-- body, or at the end of a declarative part.
-- calls do not freeze when they appear within generated bodies,
-- (including the body of another expression function) which would
-- place the freeze node in the wrong scope. An expression function
-- is frozen in the usual fashion, by the appearance of a real body,
-- or at the end of a declarative part.
if Is_Entity_Name (Subp) and then not In_Spec_Expression
and then not Is_Expression_Function (Current_Scope)
and then
(not Is_Expression_Function (Entity (Subp))
or else Scope (Entity (Subp)) = Current_Scope)
......
......@@ -8122,19 +8122,24 @@ package body Sem_Util is
----------------------------
function Is_Expression_Function (Subp : Entity_Id) return Boolean is
Decl : constant Node_Id := Unit_Declaration_Node (Subp);
Decl : Node_Id;
begin
return Ekind (Subp) = E_Function
and then Nkind (Decl) = N_Subprogram_Declaration
and then
(Nkind (Original_Node (Decl)) = N_Expression_Function
or else
(Present (Corresponding_Body (Decl))
and then
Nkind (Original_Node
(Unit_Declaration_Node (Corresponding_Body (Decl))))
= N_Expression_Function));
if Ekind (Subp) /= E_Function then
return False;
else
Decl := Unit_Declaration_Node (Subp);
return Nkind (Decl) = N_Subprogram_Declaration
and then
(Nkind (Original_Node (Decl)) = N_Expression_Function
or else
(Present (Corresponding_Body (Decl))
and then
Nkind (Original_Node
(Unit_Declaration_Node (Corresponding_Body (Decl))))
= N_Expression_Function));
end if;
end Is_Expression_Function;
--------------
......
......@@ -894,8 +894,9 @@ package Sem_Util is
-- it is of protected, synchronized or task kind.
function Is_Expression_Function (Subp : Entity_Id) return Boolean;
-- Predicate to determine whether a function entity comes from a rewritten
-- expression function, and should be inlined unconditionally.
-- Predicate to determine whether a scope entity comes from a rewritten
-- expression function call, and should be inlined unconditionally. Also
-- used to determine that such a call does not constitute a freeze point.
function Is_False (U : Uint) return Boolean;
pragma Inline (Is_False);
......
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