diff options
author | Michael Forney <mforney@mforney.org> | 2019-04-14 12:28:14 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2019-04-14 12:42:12 -0700 |
commit | ea4a14c7a4943498f49c26824d68a8d4776c5ddc (patch) | |
tree | 27c7b45778132a2badbecf9b3dc0b4d9ada4d44e /expr.c | |
parent | c662950252c041e01b64b829921cb5e79a2e2bb6 (diff) |
Initial support for loading/storing bit-fields
Diffstat (limited to 'expr.c')
-rw-r--r-- | expr.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -562,12 +562,18 @@ postfixexpr(struct scope *s, struct expr *r) m = typemember(t, tok.lit, &offset); if (!m) error(&tok.loc, "struct/union has no member named '%s'", tok.lit); - 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(m->type, tq | m->qual)); - e = mkunaryexpr(TMUL, r); - e->lvalue = lvalue; + r = mkunaryexpr(TMUL, r); + r->lvalue = lvalue; + if (m->bits.before || m->bits.after) { + e = mkexpr(EXPRBITFIELD, r->type); + e->lvalue = lvalue; + e->bitfield.base = r; + e->bitfield.bits = m->bits; + } else { + e = r; + } next(); break; case TINC: |