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 <[email protected]>
This commit is contained in:
Lars-Peter Clausen
2026-07-18 17:07:18 -07:00
parent 3c3f46099d
commit fa233f9063
+4 -1
View File
@@ -2614,6 +2614,7 @@ simple_type_or_string /* IEEE1800-2005: A.2.2.1 */
statement /* IEEE1800-2005: A.6.4 */ statement /* IEEE1800-2005: A.6.4 */
: attribute_list_opt statement_item : attribute_list_opt statement_item
{ pform_bind_attributes($2->attributes, $1); { pform_bind_attributes($2->attributes, $1);
if (!$1) @$ = @2;
$$ = $2; $$ = $2;
} }
; ;
@@ -2625,7 +2626,9 @@ statement_or_null /* IEEE1800-2005: A.6.4 */
: statement : statement
{ $$ = $1; } { $$ = $1; }
| attribute_list_opt ';' | attribute_list_opt ';'
{ $$ = 0; } { if (!$1) @$ = @2;
$$ = 0;
}
; ;
stream_expression stream_expression