From facf7b2a0c7c81e65275685641742e0a91426090 Mon Sep 17 00:00:00 2001 From: Colin Leroy-Mira Date: Sun, 6 Jul 2025 18:35:21 +0200 Subject: [PATCH] Add basic test for incsp optimisation --- test/val/bug2748.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test/val/bug2748.c diff --git a/test/val/bug2748.c b/test/val/bug2748.c new file mode 100644 index 000000000..c1bee3257 --- /dev/null +++ b/test/val/bug2748.c @@ -0,0 +1,32 @@ +#include "unittest.h" + +int func(int expr) +{ + { + int i = 5; + return i; + } +} + +static size_t c_sp_before, c_sp_after; + +TEST +{ + int a = 11; + int b; + + __asm__("lda c_sp"); + __asm__("ldx c_sp+1"); + c_sp_before = __AX__; + + b = func(a); + + __asm__("lda c_sp"); + __asm__("ldx c_sp+1"); + c_sp_after = __AX__; + + ASSERT_IsTrue(c_sp_before == c_sp_after, "Unexpected stack pointer"); + ASSERT_IsTrue(b == 5, "Wrong value for b"); + ASSERT_IsTrue(a == 11, "Wrong value for a"); +} +ENDTEST