scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 687959e5e85e73b4fbdd9871eea90d5b56c3f577
parent c79ab0b02b6d74f4fa1b19e82201df136b8ae2e6
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun, 17 Jan 2016 21:55:35 +0100

Do not return after found a sub compound in initlist()

We can have something like: {{}, {}}, so we only have to pass to the
next element instead of returning.

Diffstat:
Mcc1/init.c | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/cc1/init.c b/cc1/init.c @@ -79,7 +79,7 @@ designation(Init *ip) default: return ip; } - dp->pos = (*fun)(ip); + ip->curpos = (*fun)(ip); expect('='); return ip; } @@ -88,6 +88,7 @@ static Node * initlist(Symbol *sym, Type *tp) { struct inititlizer *ip; + struct designator *dp; int toomany = 0; TINT n; Type *newtp; @@ -131,9 +132,10 @@ initlist(Symbol *sym, Type *tp) sym = NULL; break; } - if (accept('{')) - return initlist(sym, tp); - ip->head->expr = assign(NULL); + dp = ip->head; + dp->pos = ip->curpos; + /* TODO: pass the correct parameters to initlist */ + dp->expr = (accept('{')) ? initlist(sym, tp) : assign(NULL); if (!accept(',')) break;