diff mbox series

[COMMITTED,11/17] ada: Restructure continuation message for pretty printing

Message ID 20240829130750.1651060-11-poulhies@adacore.com
State New
Headers show
Series [COMMITTED,01/17] ada: Update documentation for conditional when constructs | expand

Commit Message

Marc Poulhiès Aug. 29, 2024, 1:07 p.m. UTC
From: Viljar Indus <indus@adacore.com>

Continuation messages should have the same location
as the main message. If the goal is to point to a different
location then Error_Msg_Sloc should be used to change
the location of the continuation message.

gcc/ada/

	* par-ch4.adb (P_Name): Use Error_Msg_Sloc for the location of the
	continuation message.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/par-ch4.adb | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/gcc/ada/par-ch4.adb b/gcc/ada/par-ch4.adb
index 8b491c2cfd7..e76b0d8bea6 100644
--- a/gcc/ada/par-ch4.adb
+++ b/gcc/ada/par-ch4.adb
@@ -218,6 +218,8 @@  package body Ch4 is
       Arg_List  : List_Id := No_List; -- kill junk warning
       Attr_Name : Name_Id := No_Name; -- kill junk warning
 
+      Error_Loc : Source_Ptr;
+
    begin
       --  Case of not a name
 
@@ -889,13 +891,16 @@  package body Ch4 is
          ("positional parameter association " &
            "not allowed after named one");
 
+      Error_Loc := Token_Ptr;
+
       Expr_Node := P_Expression_If_OK;
 
       --  Leaving the '>' in an association is not unusual, so suggest
       --  a possible fix.
 
       if Nkind (Expr_Node) = N_Op_Eq then
-         Error_Msg_N ("\maybe `='>` was intended", Expr_Node);
+         Error_Msg_Sloc := Sloc (Expr_Node);
+         Error_Msg ("\maybe `='>` was intended #", Error_Loc);
       end if;
 
       --  We go back to scanning out expressions, so that we do not get