https://gcc.gnu.org/g:a1b7ea3ef93a5cef11d8202ffd9160dd623e82be

commit r16-3704-ga1b7ea3ef93a5cef11d8202ffd9160dd623e82be
Author: Viljar Indus <[email protected]>
Date:   Thu Aug 7 13:36:55 2025 +0300

    ada: Add location info to policy difference errors
    
    gcc/ada/ChangeLog:
    
            * ghost.adb (Check_Ghost_Completion): Add location info
            to the policy messages.
            (Check_Ghost_Policy): Likwise.

Diff:
---
 gcc/ada/ghost.adb | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/gcc/ada/ghost.adb b/gcc/ada/ghost.adb
index 9474beb26b2c..f0c62f3dc064 100644
--- a/gcc/ada/ghost.adb
+++ b/gcc/ada/ghost.adb
@@ -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;

Reply via email to