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 abec185dead30d4034721619befc847f4c05621c
parent 70cbf1e90934b1902769d53a4a43c0e6aa200dfd
Author: Michael Forney <mforney@mforney.org>
Date:   Fri,  5 Apr 2019 15:59:12 -0700

Separate unqualified type and qualifiers in struct member

Diffstat:
Mcc.h | 1+
Mdecl.c | 3++-
Mexpr.c | 2+-
Mqbe.c | 4++--
4 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/cc.h b/cc.h @@ -172,6 +172,7 @@ struct bitfield { struct member { char *name; struct type *type; + enum typequal qual; uint64_t offset; struct bitfield bits; struct member *next; diff --git a/decl.c b/decl.c @@ -643,7 +643,8 @@ addmember(struct structbuilder *b, struct type *mt, char *name, int align, uint6 assert(mt->align > 0); if (name || width == -1) { m = xmalloc(sizeof(*m)); - m->type = mt; + m->qual = QUALNONE; + m->type = typeunqual(mt, &m->qual); m->name = name; m->next = NULL; *b->last = m; diff --git a/expr.c b/expr.c @@ -562,7 +562,7 @@ postfixexpr(struct scope *s, struct expr *r) if (m->bits.before || m->bits.after) error(&tok.loc, "bit-field access is not yet supported"); r = mkbinaryexpr(&tok.loc, TADD, r, mkconstexpr(&typeulong, offset)); - r = exprconvert(r, mkpointertype(mkqualifiedtype(m->type, tq))); + r = exprconvert(r, mkpointertype(mkqualifiedtype(m->type, tq | m->qual))); e = mkunaryexpr(TMUL, r); e->lvalue = lvalue; next(); diff --git a/qbe.c b/qbe.c @@ -1007,7 +1007,7 @@ emittype(struct type *t) for (m = t->structunion.members; m; m = m->next) { for (sub = m->type; sub->kind == TYPEARRAY; sub = sub->base) ; - emittype(typeunqual(sub, NULL)); + emittype(sub); } fputs("type :", stdout); emitname(&t->repr->abi); @@ -1017,7 +1017,7 @@ emittype(struct type *t) fputs("{ ", stdout); for (i = 1, sub = m->type; sub->kind == TYPEARRAY; sub = sub->base) i *= sub->array.length; - emitrepr(typeunqual(sub, NULL)->repr, true, true); + emitrepr(sub->repr, true, true); if (i > 1) printf(" %" PRIu64, i); if (t->kind == TYPEUNION)