From 85a68dbdcd0200a711bacda9c7170129350813c8 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Fri, 5 Jun 2026 23:32:39 +0200 Subject: Refer to the original file for unused objects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When warning users on unused objects (e.g. variables, proc's), we have to pick up the source of origin for this warning. In places where the original PNode is not available, then we go with the last source we have at hand, as that's the usual way to go (i.e. the error occurred at the current source/context). That being said, for unused objects that's not desirable, because we might otherwise claim the error to happen on the file we first targetted, but it's way more useful to understand where the object was defined. Hence, when defining a variable, address or proc, let's actually store the PNode associated with it as well. This way the checker can hopefully get the source from this PNode and be more clear to the user. Signed-off-by: Miquel Sabaté Solà --- tests/def.s | 2 ++ tests/expected/unused_definition.txt | 1 + tests/unused_definition.s | 13 +++++++++++++ 3 files changed, 16 insertions(+) create mode 100644 tests/def.s create mode 100644 tests/expected/unused_definition.txt create mode 100644 tests/unused_definition.s (limited to 'tests') diff --git a/tests/def.s b/tests/def.s new file mode 100644 index 0000000..a9327d4 --- /dev/null +++ b/tests/def.s @@ -0,0 +1,2 @@ + +Var = 1 diff --git a/tests/expected/unused_definition.txt b/tests/expected/unused_definition.txt new file mode 100644 index 0000000..8e851b0 --- /dev/null +++ b/tests/expected/unused_definition.txt @@ -0,0 +1 @@ +error: variable 'Var' is unused (def.s) diff --git a/tests/unused_definition.s b/tests/unused_definition.s new file mode 100644 index 0000000..144d3dd --- /dev/null +++ b/tests/unused_definition.s @@ -0,0 +1,13 @@ +.segment "HEADER" + .byte 'N', 'E', 'S', $1A + .byte $02, $01 + .byte $00 + .byte $00 + +.segment "CODE" + +;;; asan:stack full + +.include "def.s" + +nop -- cgit v1.2.3