aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Dewar <dewar@adacore.com>2014-01-27 16:28:28 +0000
committerArnaud Charlet <charlet@gcc.gnu.org>2014-01-27 17:28:28 +0100
commit1b8b4638bb5be8aa25032836a9ef9b1e79dc2d3a (patch)
tree64895a7232305338d70e6e4d65657522e8b4a198
parent42959b0c5aa6a3ff084de4b27f4b3830c417697f (diff)
downloadgcc-1b8b4638bb5be8aa25032836a9ef9b1e79dc2d3a.zip
gcc-1b8b4638bb5be8aa25032836a9ef9b1e79dc2d3a.tar.gz
gcc-1b8b4638bb5be8aa25032836a9ef9b1e79dc2d3a.tar.bz2
sem_prag.adb (Set_Convention_From_Pragma): Check that convention Ghost can only apply to functions.
2014-01-27 Robert Dewar <dewar@adacore.com> * sem_prag.adb (Set_Convention_From_Pragma): Check that convention Ghost can only apply to functions. * einfo.ads, einfo.adb (Is_Ghost_Subprogram): Add clarifying comment. From-SVN: r207135
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/einfo.adb4
-rw-r--r--gcc/ada/einfo.ads8
-rw-r--r--gcc/ada/sem_prag.adb19
4 files changed, 31 insertions, 6 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 929297b..64dc2e9 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,11 @@
2014-01-27 Robert Dewar <dewar@adacore.com>
+ * sem_prag.adb (Set_Convention_From_Pragma): Check that
+ convention Ghost can only apply to functions.
+ * einfo.ads, einfo.adb (Is_Ghost_Subprogram): Add clarifying comment.
+
+2014-01-27 Robert Dewar <dewar@adacore.com>
+
* gnat_ugn.texi: Add Short_Enums to documentation of
-gnatet/-gnateT.
diff --git a/gcc/ada/einfo.adb b/gcc/ada/einfo.adb
index e070059..eb8b78d 100644
--- a/gcc/ada/einfo.adb
+++ b/gcc/ada/einfo.adb
@@ -6886,6 +6886,10 @@ package body Einfo is
-- Is_Ghost_Entity --
---------------------
+ -- Note: coding below allows for ghost variables. They are not currently
+ -- implemented, so we will always get False for variables, but that is
+ -- expected to change in the future.
+
function Is_Ghost_Entity (Id : E) return B is
begin
if Present (Id) and then Ekind (Id) = E_Variable then
diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads
index d7fc838..808a492 100644
--- a/gcc/ada/einfo.ads
+++ b/gcc/ada/einfo.ads
@@ -2343,11 +2343,15 @@ package Einfo is
-- Is_Ghost_Entity (synthesized)
-- Applies to all entities. Yields True for a subprogram or a whole
--- object that has convention Ghost.
+-- object that has convention Ghost. For now only functions can have
+-- Ghost convention, so this will be false for other than functions,
+-- but we expect that to change in the future.
-- Is_Ghost_Subprogram (synthesized)
-- Applies to all entities. Yields True for a subprogram that has a Ghost
--- convention.
+-- convention. Note: for now, only ghost functions are allowed, so this
+-- will always be false for procedures, but that is expected to change in
+-- the future.
-- Is_Hidden (Flag57)
-- Defined in all entities. Set for all entities declared in the
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index 70f9017..624bf43 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -6029,7 +6029,8 @@ package body Sem_Prag is
-- Set convention in entity E, and also flag that the entity has a
-- convention pragma. If entity is for a private or incomplete type,
-- also set convention and flag on underlying type. This procedure
- -- also deals with the special case of C_Pass_By_Copy convention.
+ -- also deals with the special case of C_Pass_By_Copy convention,
+ -- and error checks for inappropriate convention specification.
-------------------------------
-- Diagnose_Multiple_Pragmas --
@@ -6191,6 +6192,16 @@ package body Sem_Prag is
procedure Set_Convention_From_Pragma (E : Entity_Id) is
begin
+ -- Ghost convention is allowed only for functions
+
+ if Ekind (E) /= E_Function and then C = Convention_Ghost then
+ Error_Msg_N
+ ("& may not have Ghost convention", E);
+ Error_Msg_N
+ ("\only functions are permitted to have Ghost convention", E);
+ return;
+ end if;
+
-- Ada 2005 (AI-430): Check invalid attempt to change convention
-- for an overridden dispatching operation. Technically this is
-- an amendment and should only be done in Ada 2005 mode. However,
@@ -6201,11 +6212,11 @@ package body Sem_Prag is
and then Present (Overridden_Operation (E))
and then C /= Convention (Overridden_Operation (E))
then
- -- An attempt to override a subprogram with a ghost subprogram
+ -- An attempt to override a function with a ghost function
-- appears as a mismatch in conventions.
if C = Convention_Ghost then
- Error_Msg_N ("ghost subprogram & cannot be overriding", E);
+ Error_Msg_N ("ghost function & cannot be overriding", E);
else
Error_Pragma_Arg
("cannot change convention for overridden dispatching "
@@ -6401,7 +6412,7 @@ package body Sem_Prag is
if Is_Ghost_Subprogram (E)
and then Present (Overridden_Operation (E))
then
- Error_Msg_N ("ghost subprogram & cannot be overriding", E);
+ Error_Msg_N ("ghost function & cannot be overriding", E);
end if;
-- Go to renamed subprogram if present, since convention applies to