From dd4e47ab99609cdc7187ff284dff04e54cf4950d Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Tue, 23 Apr 2013 11:45:55 +0200 Subject: [multiple changes] 2013-04-23 Ed Schonberg * 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 * exp_ch6.adb (Expand_Actuals): Test that Subp is overloadable before testing if it's an inherited operation. From-SVN: r198181 --- gcc/ada/ChangeLog | 12 ++++++++++++ gcc/ada/exp_ch6.adb | 6 ++++++ gcc/ada/sem_res.adb | 10 ++++++---- gcc/ada/sem_util.adb | 27 ++++++++++++++++----------- gcc/ada/sem_util.ads | 5 +++-- 5 files changed, 43 insertions(+), 17 deletions(-) (limited to 'gcc/ada') diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 3380383..3ff802f 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,15 @@ +2013-04-23 Ed Schonberg + + * 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 + + * exp_ch6.adb (Expand_Actuals): Test that Subp + is overloadable before testing if it's an inherited operation. + 2013-04-23 Robert Dewar * a-envvar.adb, a-envvar.ads, exp_util.adb, sem_ch12.adb: Minor diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 1be6d72..08e93c4 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -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 diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 99fd9d5..7d00399 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -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) diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index ea4fe46..172721d 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -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; -------------- diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index 3256e4c..6151315 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -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); -- cgit v1.1