diff options
| author | 2026-03-20 08:32:09 +0100 | |
|---|---|---|
| committer | 2026-03-20 08:32:12 +0100 | |
| commit | 31032275a618f74865bdc877b569eae2227e79b4 (patch) | |
| tree | 6802666330d7fa29a6375da6d32d518e60f29884 /src/c.c | |
| parent | cdc076e6adf2e8066872d30535c71e128c5375ca (diff) | |
c: better preserve source location in some cases
Diffstat (limited to 'src/c.c')
| -rw-r--r-- | src/c.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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)); + } } } |