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> 2013-04-23 Robert Dewar <dewar@adacore.com>
* a-envvar.adb, a-envvar.ads, exp_util.adb, sem_ch12.adb: Minor * a-envvar.adb, a-envvar.ads, exp_util.adb, sem_ch12.adb: Minor
......
...@@ -1719,6 +1719,11 @@ package body Exp_Ch6 is ...@@ -1719,6 +1719,11 @@ package body Exp_Ch6 is
-- subtype is elaborated before the body of the subprogram, but -- subtype is elaborated before the body of the subprogram, but
-- this is harder to verify, and there may be a redundant check. -- 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)) if (Present (Find_Aspect (E_Actual, Aspect_Predicate))
or else or else
Present (Find_Aspect (E_Actual, Aspect_Dynamic_Predicate)) Present (Find_Aspect (E_Actual, Aspect_Dynamic_Predicate))
...@@ -1727,6 +1732,7 @@ package body Exp_Ch6 is ...@@ -1727,6 +1732,7 @@ package body Exp_Ch6 is
and then not Is_Init_Proc (Subp) and then not Is_Init_Proc (Subp)
then then
if (Is_Derived_Type (E_Actual) if (Is_Derived_Type (E_Actual)
and then Is_Overloadable (Subp)
and then Is_Inherited_Operation_For_Type (Subp, E_Actual)) and then Is_Inherited_Operation_For_Type (Subp, E_Actual))
or else Is_Entity_Name (Actual) or else Is_Entity_Name (Actual)
then then
......
...@@ -5386,12 +5386,14 @@ package body Sem_Res is ...@@ -5386,12 +5386,14 @@ package body Sem_Res is
-- In Ada 2012, expression functions may be called within pre/post -- In Ada 2012, expression functions may be called within pre/post
-- conditions of subsequent functions or expression functions. Such -- conditions of subsequent functions or expression functions. Such
-- calls do not freeze when they appear within generated bodies, which -- calls do not freeze when they appear within generated bodies,
-- would place the freeze node in the wrong scope. An expression -- (including the body of another expression function) which would
-- function is frozen in the usual fashion, by the appearance of a real -- place the freeze node in the wrong scope. An expression function
-- body, or at the end of a declarative part. -- 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 if Is_Entity_Name (Subp) and then not In_Spec_Expression
and then not Is_Expression_Function (Current_Scope)
and then and then
(not Is_Expression_Function (Entity (Subp)) (not Is_Expression_Function (Entity (Subp))
or else Scope (Entity (Subp)) = Current_Scope) or else Scope (Entity (Subp)) = Current_Scope)
......
...@@ -8122,19 +8122,24 @@ package body Sem_Util is ...@@ -8122,19 +8122,24 @@ package body Sem_Util is
---------------------------- ----------------------------
function Is_Expression_Function (Subp : Entity_Id) return Boolean is function Is_Expression_Function (Subp : Entity_Id) return Boolean is
Decl : constant Node_Id := Unit_Declaration_Node (Subp); Decl : Node_Id;
begin begin
return Ekind (Subp) = E_Function if Ekind (Subp) /= E_Function then
and then Nkind (Decl) = N_Subprogram_Declaration return False;
and then
(Nkind (Original_Node (Decl)) = N_Expression_Function else
or else Decl := Unit_Declaration_Node (Subp);
(Present (Corresponding_Body (Decl)) return Nkind (Decl) = N_Subprogram_Declaration
and then and then
Nkind (Original_Node (Nkind (Original_Node (Decl)) = N_Expression_Function
(Unit_Declaration_Node (Corresponding_Body (Decl)))) or else
= N_Expression_Function)); (Present (Corresponding_Body (Decl))
and then
Nkind (Original_Node
(Unit_Declaration_Node (Corresponding_Body (Decl))))
= N_Expression_Function));
end if;
end Is_Expression_Function; end Is_Expression_Function;
-------------- --------------
......
...@@ -894,8 +894,9 @@ package Sem_Util is ...@@ -894,8 +894,9 @@ package Sem_Util is
-- it is of protected, synchronized or task kind. -- it is of protected, synchronized or task kind.
function Is_Expression_Function (Subp : Entity_Id) return Boolean; function Is_Expression_Function (Subp : Entity_Id) return Boolean;
-- Predicate to determine whether a function entity comes from a rewritten -- Predicate to determine whether a scope entity comes from a rewritten
-- expression function, and should be inlined unconditionally. -- 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; function Is_False (U : Uint) return Boolean;
pragma Inline (Is_False); 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