From f7b42b2c26481734a4214aac856b33a942c93c23 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 28 Apr 2026 16:06:33 +0200 Subject: Send an error for unused .proc's MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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à --- tests/bad_jal.s | 2 ++ tests/delayed_macro_arguments.s | 2 ++ tests/fallthrough.s | 3 +++ 3 files changed, 7 insertions(+) (limited to 'tests') 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 -- cgit v1.2.3