aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-02 19:36:50 +0900
committernsfisis <nsfisis@gmail.com>2026-05-02 19:37:27 +0900
commitee7da1ce9c1efd76bf02e7a5d2591bf8099ef0ca (patch)
tree12c5bfb3999a738bd4286334f0bb623bac0f81c9 /tests
parent76654319325efadf9ef19f4ce181397ad53f6914 (diff)
downloadducc-ee7da1ce9c1efd76bf02e7a5d2591bf8099ef0ca.tar.gz
ducc-ee7da1ce9c1efd76bf02e7a5d2591bf8099ef0ca.tar.zst
ducc-ee7da1ce9c1efd76bf02e7a5d2591bf8099ef0ca.zip
fix: stack offset calculation of local variables of functions having many parameters
`calc_lvar_stack_offset()` previously only checked the offset of the last local variables, but it might be a passed-by-stack parameter, which had a negative stack offset. With this change, `calc_lvar_stack_offset()` finds the maximum *positive* offset from local variables.
Diffstat (limited to 'tests')
-rw-r--r--tests/functions.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/functions.c b/tests/functions.c
index 6e4622c..4911d7c 100644
--- a/tests/functions.c
+++ b/tests/functions.c
@@ -100,6 +100,12 @@ int f10() {
return 12345;
}
+int f11(int* a, int* b, int* c, int* d, int* e, int* f, int* g) {
+ int x = 99;
+ int* local = &x;
+ return *a + *b + *c + *d + *e + *f + *g + *local;
+}
+
int sum(int n, ...) {
va_list args;
va_start(args, n);
@@ -143,6 +149,9 @@ int main() {
S s;
s.x = 5;
s.y = 6;
+ int v1 = 1, v2 = 2, v3 = 3, v4 = 4, v5 = 5, v6 = 6, v7 = 7;
+ ASSERT_EQ(1 + 2 + 3 + 4 + 5 + 6 + 7 + 99, f11(&v1, &v2, &v3, &v4, &v5, &v6, &v7));
+
ASSERT_EQ(1, f9(0, 1, 2, 3, 4, s, 7, 8));
ASSERT_EQ(2, f9(1, 1, 2, 3, 4, s, 7, 8));
ASSERT_EQ(3, f9(2, 1, 2, 3, 4, s, 7, 8));