aboutsummaryrefslogtreecommitdiff
path: root/init.c
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2019-04-14 13:09:02 -0700
committerMichael Forney <mforney@mforney.org>2019-04-14 13:09:02 -0700
commitb6e582d2842aa21e24a70675b760bba331dc0d72 (patch)
treea062aa83b3570188d8f5b957ec4b0de1eecc637d /init.c
parentea4a14c7a4943498f49c26824d68a8d4776c5ddc (diff)
init: Error on bit-field initializers for now
Diffstat (limited to 'init.c')
-rw-r--r--init.c11
1 files changed, 11 insertions, 0 deletions
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)