From 094ecceaaca7010c1f9236f50c7f17b4b80c58ec Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Thu, 3 Mar 2022 01:10:33 +0100 Subject: [PATCH] fix bug where non-inlined asmsub didn't always get a proper RTS, causing program crash was caused by a change in 7.8; 8ae3bad6f7e73a3913594a983939298b357c7e7e "fix rts in empty asmsub" --- .../src/prog8/compiler/astprocessing/BeforeAsmAstChanger.kt | 4 ++-- docs/source/todo.rst | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/compiler/src/prog8/compiler/astprocessing/BeforeAsmAstChanger.kt b/compiler/src/prog8/compiler/astprocessing/BeforeAsmAstChanger.kt index bd44b2146..267e73897 100644 --- a/compiler/src/prog8/compiler/astprocessing/BeforeAsmAstChanger.kt +++ b/compiler/src/prog8/compiler/astprocessing/BeforeAsmAstChanger.kt @@ -118,7 +118,7 @@ internal class BeforeAsmAstChanger(val program: Program, // add the implicit return statement at the end (if it's not there yet), but only if it's not a kernal routine. // and if an assembly block doesn't contain a rts/rti, and some other situations. - if (!subroutine.isAsmSubroutine && !subroutine.inline) { + if (!subroutine.isAsmSubroutine && (!subroutine.inline || !options.optimize)) { if(subroutine.statements.isEmpty() || (subroutine.amountOfRtsInAsm() == 0 && subroutine.statements.lastOrNull { it !is VarDecl } !is Return @@ -145,7 +145,7 @@ internal class BeforeAsmAstChanger(val program: Program, } } - if (!subroutine.inline) { + if (!subroutine.inline || !options.optimize) { if (subroutine.isAsmSubroutine && subroutine.asmAddress==null && subroutine.amountOfRtsInAsm() == 0) { // make sure the NOT INLINED asm subroutine actually has a rts at the end // (non-asm routines get a Return statement as needed, above) diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 4b0db61cb..4315231e2 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -3,9 +3,6 @@ TODO For next release ^^^^^^^^^^^^^^^^ -FIX BUG: -- wormfood noopt crash caused by a change in 7.8; 8ae3bad6f7e73a3913594a983939298b357c7e7e "fix rts in empty asmsub" - ...