aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2007-12-13 18:59:09 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2007-12-13 18:59:09 +0100
commit17cf3985108a463cd143c310b566371f54008193 (patch)
treeaa4f1056d50f24eeee9c880268699edd5e24cdf3 /gcc
parent3958c9c88249a51d81d0070a5cddb4936764e452 (diff)
downloadgcc-17cf3985108a463cd143c310b566371f54008193.zip
gcc-17cf3985108a463cd143c310b566371f54008193.tar.gz
gcc-17cf3985108a463cd143c310b566371f54008193.tar.bz2
Restore part of patch lost for PR ada/15805:
* sem_ch3.adb (Analyze_Object_Declaration): Signal an error when an access to constant is used to initialize an access value. From-SVN: r130903
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_ch3.adb14
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 3be25a1..b34132a 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -2367,6 +2367,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.