aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2007-12-07 14:37:36 +0000
committerSamuel Tardieu <sam@gcc.gnu.org>2007-12-07 14:37:36 +0000
commit9cc11b58d2dc8c70a7892d0da5836e066219ea6d (patch)
treea36f694cec9ce46a29cc1dc0435422f8a015f6fe /gcc/ada
parent2eb160f205ce2a807ecdef95b2e88652a5e3f0ed (diff)
downloadgcc-9cc11b58d2dc8c70a7892d0da5836e066219ea6d.zip
gcc-9cc11b58d2dc8c70a7892d0da5836e066219ea6d.tar.gz
gcc-9cc11b58d2dc8c70a7892d0da5836e066219ea6d.tar.bz2
sem_ch3.adb (Analyze_Object_Declaration): Signal an error when an access to constant is used to initialize an access value.
gcc/ada/ * sem_ch3.adb (Analyze_Object_Declaration): Signal an error when an access to constant is used to initialize an access value. gcc/testsuite/ * gnat.dg/specs/access_constant_decl.ads: New test. From-SVN: r130677
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog4
-rw-r--r--gcc/ada/sem_ch3.adb14
2 files changed, 18 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 9ddc6da..cd4e3a0 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -4,6 +4,10 @@
* sem_ch6.adb (Process_Formals): Prevent an access type formal
to be initialized with an access to constant object.
+ * sem_ch3.adb (Analyze_Object_Declaration): Signal an error
+ when an access to constant is used to initialize an access
+ value.
+
2007-12-07 Olivier Hainque <hainque@adacore.com>
PR ada/34173
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 5c61d00..c16b406 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -2364,6 +2364,20 @@ package body Sem_Ch3 is
Set_Is_True_Constant (Id, True);
+ -- If the initialization expression is an access to constant,
+ -- it cannot be used with an access type.
+
+ if Is_Access_Type (Etype (E))
+ and then Is_Access_Constant (Etype (E))
+ and then Is_Access_Type (T)
+ and then not Is_Access_Constant (T)
+ then
+ Error_Msg_NE ("object of type& cannot be initialized with " &
+ "an access-to-constant expression",
+ E,
+ T);
+ end if;
+
-- If we are analyzing a constant declaration, set its completion
-- flag after analyzing the expression.