From 857f0ecdab2cc3337d15540a32f5b25c1424f4de Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sat, 6 Apr 2024 13:41:43 -0700 Subject: Remove some unnecessary use of array type length --- qbe.c | 10 +++++----- type.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/qbe.c b/qbe.c index 8a19d46..8a7010a 100644 --- a/qbe.c +++ b/qbe.c @@ -1063,7 +1063,7 @@ emittype(struct type *t) static unsigned id; struct member *m, *other; struct type *sub; - unsigned long long i, off; + unsigned long long off; if (t->value || t->kind != TYPESTRUCT && t->kind != TYPEUNION) return; @@ -1096,11 +1096,11 @@ emittype(struct type *t) } else { fputs("{ ", stdout); } - for (i = 1, sub = m->type; sub->kind == TYPEARRAY; sub = sub->base) - i *= sub->u.array.length; + for (sub = m->type; sub->kind == TYPEARRAY; sub = sub->base) + ; emitclass(qbetype(sub).data, sub->value); - if (i > 1) - printf(" %llu", i); + if (m->type->size > sub->size) + printf(" %llu", m->type->size / sub->size); if (t->kind == TYPESTRUCT) { fputs(", ", stdout); /* skip subsequent members contained within the same storage unit */ diff --git a/type.c b/type.c index b533f1c..0aaff36 100644 --- a/type.c +++ b/type.c @@ -129,7 +129,7 @@ typecompatible(struct type *t1, struct type *t2) case TYPEPOINTER: goto derived; case TYPEARRAY: - if (t1->u.array.length && t2->u.array.length && t1->u.array.length != t2->u.array.length) + if (!t1->incomplete && !t2->incomplete && t1->size != t2->size) return false; goto derived; case TYPEFUNC: -- cgit v1.2.3