aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Dewar <dewar@adacore.com>2008-05-28 15:05:35 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2008-05-28 15:05:35 +0200
commit71a555b3b9c9d741380db25fd2fdc47211b5ecdf (patch)
treefb31690627a5834458cdbda545cabae658c2046f
parent6765b310618f5ce2cdd780f06b3653ecff8e355c (diff)
downloadgcc-71a555b3b9c9d741380db25fd2fdc47211b5ecdf.zip
gcc-71a555b3b9c9d741380db25fd2fdc47211b5ecdf.tar.gz
gcc-71a555b3b9c9d741380db25fd2fdc47211b5ecdf.tar.bz2
gnat_rm.texi: Add note on Old giving warning when applied to constant
2008-05-28 Robert Dewar <dewar@adacore.com> * gnat_rm.texi: Add note on Old giving warning when applied to constant * sem_attr.adb (Analyze_Attribute, case Old): Give warning if prefix is a constant From-SVN: r136078
-rw-r--r--gcc/ada/gnat_rm.texi4
-rw-r--r--gcc/ada/sem_attr.adb7
2 files changed, 11 insertions, 0 deletions
diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi
index 0d2d0ff..69baaa2 100644
--- a/gcc/ada/gnat_rm.texi
+++ b/gcc/ada/gnat_rm.texi
@@ -5803,6 +5803,10 @@ package body Old_Pkg is
end Old_Pkg;
@end smallexample
+@noindent
+Note that it is allowed to apply 'Old to a constant entity, but this will
+result in a warning, since the old and new values will always be the same.
+
@node Passed_By_Reference
@unnumberedsec Passed_By_Reference
@cindex Parameters, when passed by reference
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index 0cb2ace..14f9102 100644
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -3501,6 +3501,13 @@ package body Sem_Attr is
Error_Attr ("attribute % cannot apply to limited objects", P);
end if;
+ if Is_Entity_Name (P)
+ and then Is_Constant_Object (Entity (P))
+ then
+ Error_Msg_N
+ ("?attribute Old applied to constant has no effect", P);
+ end if;
+
-- Check that the expression does not refer to local entities
Check_Local : declare