cproc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/cproc
Log | Files | Refs | Submodules | README | LICENSE

commit ba938ae247c78838a942980dfcf9e6618a6ce610
parent 8754499cd20a79aeff1bc208941db830fb8e44a4
Author: Michael Forney <mforney@mforney.org>
Date:   Fri,  1 Mar 2019 23:10:43 -0800

init: Check for incomplete types

Fixes #28.

Diffstat:
Minit.c | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/init.c b/init.c @@ -216,11 +216,14 @@ parseinit(struct scope *s, struct type *t) struct expression *expr; struct type *base; + t = typeunqual(t, NULL); p.cur = NULL; p.sub = p.obj; p.sub->offset = 0; - p.sub->type = typeunqual(t, NULL); + p.sub->type = t; p.sub->iscur = false; + if (t->incomplete && !(t->kind == TYPEARRAY && t->array.length == 0)) + error(&tok.loc, "initializer specified for incomplete type"); for (;;) { if (p.cur) { if (tok.kind == TLBRACK || tok.kind == TPERIOD)