[Ada] Issue error on illegal ownership in SPARK
authorYannick Moy <moy@adacore.com>
Tue, 9 Jul 2019 07:53:26 +0000 (07:53 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Tue, 9 Jul 2019 07:53:26 +0000 (07:53 +0000)
Check for declaration of global variables prior to use in the ownership
checking for SPARK.

There is no impact on compilation.

2019-07-09  Yannick Moy  <moy@adacore.com>

gcc/ada/

* sem_spark.adb (Get_Perm_Or_Tree): Issue an error when
encountering unknown global variable.

From-SVN: r273267

gcc/ada/ChangeLog
gcc/ada/sem_spark.adb

index 9f6b789b983770e6e0a9678ee4e832011cb56e90..0fd03b728d9921f154b6ba4ff3de3823559876a4 100644 (file)
@@ -1,3 +1,8 @@
+2019-07-09  Yannick Moy  <moy@adacore.com>
+
+       * sem_spark.adb (Get_Perm_Or_Tree): Issue an error when
+       encountering unknown global variable.
+
 2019-07-09  Yannick Moy  <moy@adacore.com>
 
        * sem_spark.adb (Check_Expression): Change signature to take an
index 2b1991959ab1bbb83a86d95ad045075abfe75cf2..6f27d20452d5fb39b087a2fca9704781d7985176 100644 (file)
@@ -3270,7 +3270,16 @@ package body Sem_SPARK is
                C : constant Perm_Tree_Access :=
                  Get (Current_Perm_Env, Unique_Entity (Entity (N)));
             begin
-               pragma Assert (C /= null);
+               --  Except during elaboration, the root object should have been
+               --  declared and entered into the current permission
+               --  environment.
+
+               if not Inside_Elaboration
+                 and then C = null
+               then
+                  Illegal_Global_Usage (N);
+               end if;
+
                return (R => Unfolded, Tree_Access => C);
             end;