summaryrefslogtreecommitdiff
path: root/gcc/ada/sem_ch3.adb
diff options
context:
space:
mode:
authorsam <sam@138bc75d-0d04-0410-961f-82ee72b054a4>2007-12-07 14:37:36 +0000
committersam <sam@138bc75d-0d04-0410-961f-82ee72b054a4>2007-12-07 14:37:36 +0000
commitaf4565b381fae63fa5c2ebd1f0499c0f46df1472 (patch)
treea36f694cec9ce46a29cc1dc0435422f8a015f6fe /gcc/ada/sem_ch3.adb
parentfdaa82c9aad9880f9ab29979f7fd2ad0747092ec (diff)
downloadgcc-af4565b381fae63fa5c2ebd1f0499c0f46df1472.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@130677 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/sem_ch3.adb')
-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 5c61d00943f..c16b4066d84 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.