]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Restore part of patch lost for PR ada/15805:
authorArnaud Charlet <charlet@gcc.gnu.org>
Thu, 13 Dec 2007 17:59:09 +0000 (18:59 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Thu, 13 Dec 2007 17:59:09 +0000 (18:59 +0100)
* sem_ch3.adb (Analyze_Object_Declaration): Signal an error
when an access to constant is used to initialize an access
value.

From-SVN: r130903

gcc/ada/sem_ch3.adb

index 3be25a19fe000de161724c0816dd894b2955c26c..b34132a22a1701d3adeae161be3c2666cefc08e3 100644 (file)
@@ -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.