aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/c_eval.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2026-03-18 23:10:25 +0100
committerlemon <lsof@mailbox.org>2026-03-18 23:10:25 +0100
commit1b782f049fa96d7ebccf93ad2b05fc30b938c870 (patch)
treed4048328308d676f05a9312af63e55e09459da8e /src/c_eval.c
parent626c927bb70519e630402093ff4fba432d2ac8c5 (diff)
c: fix edge cases with zero sized bitfields and static initializers
Diffstat (limited to 'src/c_eval.c')
-rw-r--r--src/c_eval.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/c_eval.c b/src/c_eval.c
index eff7e94..dce1457 100644
--- a/src/c_eval.c
+++ b/src/c_eval.c
@@ -139,7 +139,7 @@ truthy(const Expr *ex)
static bool
unop(Expr *ex, enum evalmode mode)
{
- Expr *sub = ex->sub;
+ Expr *sub = ex->sub, ex2;
if (mode >= EVSTATICINI && ex->t == EDEREF) {
uvlong off;
@@ -175,10 +175,14 @@ unop(Expr *ex, enum evalmode mode)
p = sub->sub[1].s.p, len = sub->sub[1].s.n;
csiz = typesize(typechild(sub->sub[1].ty));
goto StrRead;
+ } else if (ex->ty.t == TYARRAY && eval(sub, mode)) {
+ sub->ty = ex->ty;
+ *ex = *sub;
+ return 1;
} else return 0;
} else if (ex->t == EADDROF) {
assert(ex->ty.t == TYPTR);
- Expr ex2 = staticaddrof(ex->sub, mode);
+ ex2 = staticaddrof(ex->sub, mode);
if (!ex2.t) return 0;
ex2.span = ex->span;
ex2.ty = ex->ty;