]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix ghost condition for level dependencies for assignments
authorViljar Indus <indus@adacore.com>
Tue, 2 Sep 2025 09:25:07 +0000 (12:25 +0300)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 15 Sep 2025 12:59:31 +0000 (14:59 +0200)
gcc/ada/ChangeLog:

* ghost.adb (Check_Assignment_Policies): The level of the assignee
should depend on the level of the region.

gcc/ada/ghost.adb

index 40075bdf0a6b50e81f7f41d8b085fe989cd01b03..37f82ca849f7f3b3a31a69acf6a08c0207fa109c 100644 (file)
@@ -1913,12 +1913,14 @@ package body Ghost is
               ("\& is modified in a region with `Ignore`", N, Assignee);
          end if;
 
+         --  If an assignment to a part of a ghost variable occurs in a ghost
+         --  entity, then the variable should be assertion-level-dependent on
+         --  this entity (SPARK RM 6.9(18)).
+
          if Present (Region_Level)
            and then not Is_Assertion_Level_Dependent
-                          (Region_Level, Assignee_Level)
+                          (Assignee_Level, Region_Level)
          then
-            Error_Msg_Sloc := Sloc (N);
-
             Error_Msg_N (Assertion_Level_Error_Msg, N);
             Error_Msg_Name_1 := Chars (Assignee_Level);
             Error_Msg_NE ("\& has assertion level %", N, Assignee);