diff options
author | Michael Forney <mforney@mforney.org> | 2019-04-05 15:59:12 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2019-04-06 12:01:38 -0700 |
commit | abec185dead30d4034721619befc847f4c05621c (patch) | |
tree | fc54dfcba11890da5fa33d94f02643fb41b30b00 | |
parent | 70cbf1e90934b1902769d53a4a43c0e6aa200dfd (diff) |
Separate unqualified type and qualifiers in struct member
-rw-r--r-- | cc.h | 1 | ||||
-rw-r--r-- | decl.c | 3 | ||||
-rw-r--r-- | expr.c | 2 | ||||
-rw-r--r-- | qbe.c | 4 |
4 files changed, 6 insertions, 4 deletions
@@ -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; @@ -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; @@ -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(); @@ -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) |