cproc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/cproc
Log | Files | Refs | Submodules | README | LICENSE

commit 240af0bbd03f4eef58a5b7c6da9f74a13682f172
parent ed051588b3889f6ad8ed89651dc4f29801bf198c
Author: Nihal Jere <nihal@nihaljere.xyz>
Date:   Thu, 25 Mar 2021 00:06:22 -0500

qbe.c: always output strings as byte type

As qbe only understands byte-width characters, this lets us give it for
example wide characters strings as byte-width string literals

Diffstat:
Mqbe.c | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/qbe.c b/qbe.c @@ -1326,7 +1326,11 @@ emitdata(struct decl *d, struct init *init) */ bits &= 0x7f >> (cur->bits.after + 7) % 8; } else { - printf("%c ", cur->expr->type->kind == TYPEARRAY ? cur->expr->type->base->repr->ext : cur->expr->type->repr->ext); + /* qbe does not support string literals with widths larger than 'b' */ + if (cur->expr->kind == EXPRSTRING) + printf("b "); + else + printf("%c ", cur->expr->type->kind == TYPEARRAY ? cur->expr->type->base->repr->ext : cur->expr->type->repr->ext); dataitem(cur->expr, cur->end - cur->start); fputs(", ", stdout); }