From fa233f9063fce6f6262aa3d1368a071892ddeb1d Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 18 Jul 2026 17:07:18 -0700 Subject: [PATCH] Fix locations of unattributed statements The `statement` and null-statement rules start with an optional attribute list. When it is empty, the reduced location starts at the previous token instead of the statement. Diagnostics using that location can consequently point to the beginning of the source file. Use the statement or semicolon location when no attributes are present. Signed-off-by: Lars-Peter Clausen --- parse.y | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/parse.y b/parse.y index 83d149b30..227b36007 100644 --- a/parse.y +++ b/parse.y @@ -2614,6 +2614,7 @@ simple_type_or_string /* IEEE1800-2005: A.2.2.1 */ statement /* IEEE1800-2005: A.6.4 */ : attribute_list_opt statement_item { pform_bind_attributes($2->attributes, $1); + if (!$1) @$ = @2; $$ = $2; } ; @@ -2625,7 +2626,9 @@ statement_or_null /* IEEE1800-2005: A.6.4 */ : statement { $$ = $1; } | attribute_list_opt ';' - { $$ = 0; } + { if (!$1) @$ = @2; + $$ = 0; + } ; stream_expression