From f28f255f777fc99031eed96ce42d6fbfc2e2790d Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sun, 14 Apr 2024 23:56:06 +0300 Subject: add param and return struct handling --- src/ast.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/ast.c') diff --git a/src/ast.c b/src/ast.c index df016a8..ad905ae 100644 --- a/src/ast.c +++ b/src/ast.c @@ -677,7 +677,7 @@ size_t align3k(size_t o) static size_t struct_size(struct type *t) { if (t->size != -1) - return t->size; + return (size_t)t->size; size_t size = 0; foreach_node(n, struct_body(t->d)) { @@ -691,7 +691,7 @@ static size_t struct_size(struct type *t) size += sz; } - t->size = size; + t->size = (ssize_t)size; return size; } @@ -721,9 +721,11 @@ size_t type_offsetof(struct type *t, char *m) if (same_id(var_id(n), m)) break; - size_t sz = type_size(n->t); - if (sz > 2) + size_t size = type_size(n->t); + if (size > 2) offset = align3k(offset); + + offset += size; } return offset; -- cgit v1.3