[PATCH 3/3] algol68: Improve location tracking

Pietro Monteiro pietro@sociotechnical.xyz
Sun Sep 13 05:38:05 GMT 2026


Create a location that covers the node text and has the caret pointing
to the start of the text.

gcc/algol68/ChangeLog:

        * a68-parser.cc (a68_get_node_location): Return a location
	that covers the whole span of the node.

Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
---
 gcc/algol68/a68-parser.cc | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gcc/algol68/a68-parser.cc b/gcc/algol68/a68-parser.cc
index 878d9d6cd9b..40ebe507492 100644
--- a/gcc/algol68/a68-parser.cc
+++ b/gcc/algol68/a68-parser.cc
@@ -1155,7 +1155,14 @@ a68_get_node_location (NODE_T *p)
 
   const char *start_pos = CHAR_IN_LINE (INFO (p));
   location_t start_loc = a68_get_line_location (line, start_pos);
-  return start_loc;
+
+  if (NSYMBOL (p) == NO_TEXT)
+    return start_loc;
+
+  const char *end_pos = start_pos + strlen (NSYMBOL (p)) - 1;
+  location_t end_loc = a68_get_line_location (line, end_pos);
+
+  return make_location (start_loc, start_loc, end_loc);
 }
 
 /* Get the location of POS inside LINE as a GCC location.  */
-- 
2.54.0



More information about the Algol68 mailing list