From b6e582d2842aa21e24a70675b760bba331dc0d72 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sun, 14 Apr 2019 13:09:02 -0700 Subject: init: Error on bit-field initializers for now --- init.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/init.c b/init.c index 0d6621c..2f4d62c 100644 --- a/init.c +++ b/init.c @@ -197,6 +197,12 @@ advance(struct initparser *p) } } +static bool +isbitfield(struct member *m) +{ + return m->bits.before || m->bits.after; +} + /* 6.7.9 Initialization */ struct init * parseinit(struct scope *s, struct type *t) @@ -259,6 +265,11 @@ parseinit(struct scope *s, struct type *t) focus(&p); } add: + if (p.sub > p.obj) { + t = p.sub[-1].type; + if ((t->kind == TYPESTRUCT || t->kind == TYPEUNION) && isbitfield(p.sub[-1].mem)) + error(&tok.loc, "bit-field initializers are not yet supported"); + } initadd(&init, mkinit(p.sub->offset, p.sub->offset + p.sub->type->size, expr)); for (;;) { if (p.sub->type->kind == TYPEARRAY && p.sub->type->incomplete) -- cgit v1.2.3