scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 0beb99d6fdbf41b0f7781f5053ed470f7bc83610
parent 1cb04eea49563c01c1c9d4cc388bbe2cb95292fc
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu,  3 Nov 2022 07:44:04 +0100

cc2/qbe: Accept casts to small int sizes

Qbe doesn't accept conversions to types smaller than 4 bytes
and the truncation is done at the store stage.

Diffstat:
Msrc/cmd/cc/cc2/target/qbe/cgen.c | 2++
1 file changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/cmd/cc/cc2/target/qbe/cgen.c b/src/cmd/cc/cc2/target/qbe/cgen.c @@ -282,6 +282,8 @@ cast(Type *td, Node *np) if (d_isint && s_isint) { /* conversion from int to int */ + if (td->size < 4) + td->size = 4; if (td->size <= ts->size) { np->type = *td; return np;