diff mbox

[Ada] Improved message for the restriction use of unconstrained type in SPARK

Message ID 20110902101044.GA8335@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Sept. 2, 2011, 10:10 a.m. UTC
When the SPARK restriction mode was set, check that a declaration of 
unconstrained type is allowed only for constants of type string.

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-09-02  Marc Sango  <sango@adacore.com>

	* sem_ch3.adb (Analyze_Object_Declaration): Change
	comment and add additional check to differentiate constant of
	type string from others unconstrained type.
diff mbox

Patch

Index: sem_ch3.adb
===================================================================
--- sem_ch3.adb	(revision 178461)
+++ sem_ch3.adb	(working copy)
@@ -3320,13 +3320,12 @@ 
                --  In SPARK, a declaration of unconstrained type is allowed
                --  only for constants of type string.
 
-               --  Why no check for Comes_From_Source here, seems wrong ???
-               --  Where is check to differentiate string case ???
+               if Nkind (E) = N_String_Literal then
+                  Check_SPARK_Restriction
+                    ("declaration of object of unconstrained type not allowed",
+                     E);
+               end if;
 
-               Check_SPARK_Restriction
-                 ("declaration of object of unconstrained type not allowed",
-                  E);
-
                --  Unconstrained variables not allowed in Ada 83 mode
 
                if Ada_Version = Ada_83