diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-12-13 17:59:09 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-12-13 17:59:09 +0000 |
commit | a076435485905f4902cec6cfa3d7b20abddfd090 (patch) | |
tree | aa4f1056d50f24eeee9c880268699edd5e24cdf3 /gcc/ada | |
parent | a634298771087aa45566135c02aef7751a34dd2a (diff) | |
download | gcc-a076435485905f4902cec6cfa3d7b20abddfd090.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@130903 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/sem_ch3.adb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 3be25a19fe0..b34132a22a1 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. |