aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/c.c
diff options
context:
space:
mode:
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));
+ }
}
}