aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/c.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2026-03-20 08:32:09 +0100
committerlemon <lsof@mailbox.org>2026-03-20 08:32:12 +0100
commit31032275a618f74865bdc877b569eae2227e79b4 (patch)
tree6802666330d7fa29a6375da6d32d518e60f29884 /src/c.c
parentcdc076e6adf2e8066872d30535c71e128c5375ca (diff)
c: better preserve source location in some cases
Diffstat (limited to 'src/c.c')
-rw-r--r--src/c.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/c.c b/src/c.c
index fcde10e..c6adb4c 100644
--- a/src/c.c
+++ b/src/c.c
@@ -1233,10 +1233,12 @@ Unary:
ty = unops[nunop].ty;
if (!castcheck(ty, &ex))
error(&span, "cannot cast value of type '%ty' to '%ty'", ex.ty, ty);
- if (ex.t == ENUMLIT && isint(ex.ty) && ty.t == TYPTR)
+ if (ex.t == ENUMLIT && isint(ex.ty) && ty.t == TYPTR) {
ex.ty = ty;
- else
+ ex.span = span;
+ } else {
ex = mkexpr(ECAST, span, ty, .sub = exprdup(cm, &ex));
+ }
}
}