aboutsummaryrefslogtreecommitdiff
path: root/expr.c
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2019-04-14 12:28:14 -0700
committerMichael Forney <mforney@mforney.org>2019-04-14 12:42:12 -0700
commitea4a14c7a4943498f49c26824d68a8d4776c5ddc (patch)
tree27c7b45778132a2badbecf9b3dc0b4d9ada4d44e /expr.c
parentc662950252c041e01b64b829921cb5e79a2e2bb6 (diff)
Initial support for loading/storing bit-fields
Diffstat (limited to 'expr.c')
-rw-r--r--expr.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/expr.c b/expr.c
index a824873..4a746bc 100644
--- a/expr.c
+++ b/expr.c
@@ -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: