diff options
| author | 2026-04-13 20:15:55 +0200 | |
|---|---|---|
| committer | 2026-04-13 20:15:55 +0200 | |
| commit | dc0d3db1f0527b5b50df094bb7ce0f6c9020f60c (patch) | |
| tree | 400e1c5abab582bb1de15aaa1ca9bcb2abbc18af /src | |
| parent | 798900fdeb9b7d404572c97cf0adb7b1c09d5096 (diff) | |
c: implement explicit cast complex -> scalar
Diffstat (limited to 'src')
| -rw-r--r-- | src/c.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -3634,9 +3634,13 @@ compileexpr(Function *fn, const Expr *ex, bool discard) } /* fallthru */ case EPLUS: - r = compileexpr(fn, sub, discard); - if (discard) return NOREF; - r = scalarcvt(fn, ex->ty, sub->ty, r); + if (!iscomplex(sub->ty) || discard) { + r = compileexpr(fn, sub, discard); + if (discard) return NOREF; + r = scalarcvt(fn, ex->ty, sub->ty, r); + } else { + r = complex2scalar(fn, ex->ty, sub); + } if (isint(ex->ty) && (typesize(ex->ty) < typesize(sub->ty) || issigned(ex->ty) != issigned(sub->ty))) return narrow(fn, type2cls[scalartypet(ex->ty)], ex->ty, r, 0); return r; |