scc

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

commit 1ad61425f50fc4f6dc66ccbc6bca4c6330b8027c
parent afd74c04166cc70a18f519ffab65c6e9cf125e86
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri,  5 Jul 2013 21:51:40 +0200

Fix bug in decl

decl was returning NULL in the case of empty declarations, and in
this case it means no more declarations were scanned. This patch
force to decl() to follow scanning until it find a correct
correct declaration, or a non declaration.

Diffstat:
Mdecl.c | 13+++++--------
1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/decl.c b/decl.c @@ -216,25 +216,22 @@ struct node * decl(void) { register struct ctype *tp; - register struct node *np = NULL; +repeat: if (!(tp = spec())) { if (curctx != CTX_OUTER || yytoken != IDEN) - goto end; + return NULL; tp = newctype(); tp->type = INT; warning_error(options.implicit, "data definition has no type or storage class"); - } - if (accept(';')) { + } else if (accept(';')) { warning_error(options.useless, "useless type name in empty declaration"); delctype(tp); - } else { - np = listdcl(tp); + goto repeat; } - -end: return np; + return listdcl(tp); } void