aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2013-04-23 11:45:55 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2013-04-23 11:45:55 +0200
commitdd4e47ab99609cdc7187ff284dff04e54cf4950d (patch)
tree28048c0577165934f18995fe4e2c340933927011 /gcc/ada
parent872c2f37682753caf8bc05e17a63962382c83798 (diff)
downloadgcc-dd4e47ab99609cdc7187ff284dff04e54cf4950d.zip
gcc-dd4e47ab99609cdc7187ff284dff04e54cf4950d.tar.gz
gcc-dd4e47ab99609cdc7187ff284dff04e54cf4950d.tar.bz2
[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
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog12
-rw-r--r--gcc/ada/exp_ch6.adb6
-rw-r--r--gcc/ada/sem_res.adb10
-rw-r--r--gcc/ada/sem_util.adb27
-rw-r--r--gcc/ada/sem_util.ads5
5 files changed, 43 insertions, 17 deletions
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 <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
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);