From: Arnaud Charlet Date: Thu, 13 Dec 2007 17:59:09 +0000 (+0100) Subject: Restore part of patch lost for PR ada/15805: X-Git-Tag: releases/gcc-4.3.0~999 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=17cf3985108a463cd143c310b566371f54008193;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 3be25a19fe00..b34132a22a17 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.