aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2026-04-28 16:06:33 +0200
committerMiquel Sabaté Solà <mssola@mssola.com>2026-04-28 16:23:14 +0200
commitf7b42b2c26481734a4214aac856b33a942c93c23 (patch)
treeb74cf59ddc46af97cfc8e67ab2d60164c454f93d /tests
parentb489dd284cd6388779fef60c7283fcaf3a090cd6 (diff)
downloadtools.nes-f7b42b2c26481734a4214aac856b33a942c93c23.tar.gz
tools.nes-f7b42b2c26481734a4214aac856b33a942c93c23.zip
Send an error for unused .proc's
We cannot safely detect all scenarios in which there is dead code, but we can safely do it for .proc's. Even if they are not called directly, they might be referenced via jump tables and shenanigans like that. Long story short, if you are not referencing a .proc in any meaningful way, then we have dead code. A pattern could also be given in which a function that was too long has been splitted into smaller functions which are not called directly. This is, in my opinion, an anti-pattern (as we generally expect an rts or a jmp from .proc's), and anyways can be avoided via the use of __fallthrough__ if the programmer is really set to write this kind of code. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/bad_jal.s2
-rw-r--r--tests/delayed_macro_arguments.s2
-rw-r--r--tests/fallthrough.s3
3 files changed, 7 insertions, 0 deletions
diff --git a/tests/bad_jal.s b/tests/bad_jal.s
index 5fa2316..ddbb716 100644
--- a/tests/bad_jal.s
+++ b/tests/bad_jal.s
@@ -17,4 +17,6 @@
rts
.endproc
+jsr foo
+
;;; asan:stack full
diff --git a/tests/delayed_macro_arguments.s b/tests/delayed_macro_arguments.s
index acd3910..2c34d8c 100644
--- a/tests/delayed_macro_arguments.s
+++ b/tests/delayed_macro_arguments.s
@@ -38,6 +38,8 @@
inx
.endmacro
+__fallthrough__ Explosions::init
+
.scope Explosions
.proc init
@loop:
diff --git a/tests/fallthrough.s b/tests/fallthrough.s
index 878b5e4..f24bf1a 100644
--- a/tests/fallthrough.s
+++ b/tests/fallthrough.s
@@ -6,6 +6,8 @@
.segment "CODE"
+__fallthrough__ foo
+
.proc foo
lda #0
__fallthrough__ bar
@@ -20,6 +22,7 @@ __fallthrough__ bar
.proc other
rts
+ __fallthrough__ Scope::foo
.endproc
.scope Scope