]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Add location info to policy difference errors
authorViljar Indus <indus@adacore.com>
Thu, 7 Aug 2025 10:36:55 +0000 (13:36 +0300)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 9 Sep 2025 12:39:57 +0000 (14:39 +0200)
gcc/ada/ChangeLog:

* ghost.adb (Check_Ghost_Completion): Add location info
to the policy messages.
(Check_Ghost_Policy): Likwise.

gcc/ada/ghost.adb

index 9474beb26b2cb3bed2f6c9f11a02dd3014480a23..f0c62f3dc064e582fa9e38da232815ae869b0bfc 100644 (file)
@@ -216,19 +216,19 @@ package body Ghost is
       if Is_Checked_Ghost_Entity (Prev_Id)
         and then Policy = Name_Ignore
       then
-         Error_Msg_Sloc := Sloc (Compl_Id);
-
          Error_Msg_N (Ghost_Policy_Error_Msg, Prev_Id);
-         Error_Msg_N ("\& declared with ghost policy `Check`", Prev_Id);
+         Error_Msg_Sloc := Sloc (Prev_Id);
+         Error_Msg_N ("\& declared # with ghost policy `Check`", Prev_Id);
+         Error_Msg_Sloc := Sloc (Compl_Id);
          Error_Msg_N ("\& completed # with ghost policy `Ignore`", Prev_Id);
 
       elsif Is_Ignored_Ghost_Entity (Prev_Id)
         and then Policy = Name_Check
       then
-         Error_Msg_Sloc := Sloc (Compl_Id);
-
          Error_Msg_N (Ghost_Policy_Error_Msg, Prev_Id);
-         Error_Msg_N ("\& declared with ghost policy `Ignore`", Prev_Id);
+         Error_Msg_Sloc := Sloc (Prev_Id);
+         Error_Msg_N ("\& declared # with ghost policy `Ignore`", Prev_Id);
+         Error_Msg_Sloc := Sloc (Compl_Id);
          Error_Msg_N ("\& completed # with ghost policy `Check`", Prev_Id);
       end if;
    end Check_Ghost_Completion;
@@ -871,7 +871,8 @@ package body Ghost is
            and then Known_To_Be_Assigned (Ref)
          then
             Error_Msg_N  (Ghost_Policy_Error_Msg, Ref);
-            Error_Msg_NE ("\& declared with ghost policy `Check`", Ref, Id);
+            Error_Msg_Sloc := Sloc (Id);
+            Error_Msg_NE ("\& declared # with ghost policy `Check`", Ref, Id);
             Error_Msg_Sloc := Sloc (Ref);
             Error_Msg_NE ("\& used # with ghost policy `Ignore`",  Ref, Id);
          end if;
@@ -892,7 +893,8 @@ package body Ghost is
          if Is_Ignored_Ghost_Entity (Id) and then Applic_Policy = Check
          then
             Error_Msg_N  (Ghost_Policy_Error_Msg,  Ref);
-            Error_Msg_NE ("\& declared with ghost policy `Ignore`", Ref, Id);
+            Error_Msg_Sloc := Sloc (Id);
+            Error_Msg_NE ("\& declared # with ghost policy `Ignore`", Ref, Id);
             Error_Msg_Sloc := Sloc (Ref);
             Error_Msg_NE ("\& used # with ghost policy `Check`",    Ref, Id);
          end if;