scc

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

commit f83f8e2064258e2d96e94b4702943ddf1b30239e
parent d40e75a1f12f03a658fe8e89f84e672baf981b97
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun, 29 Jul 2012 10:55:55 +0200

Removed return value in listdcl

After a function is not needed a semi colon. One way of handling this
situation is let to listdcl return a value indicating a function was
declared, or better expect the semi colon in listdcl itself.

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

diff --git a/decl.c b/decl.c @@ -125,7 +125,7 @@ static void declarator(void) pushtype(*bp); } -static unsigned char listdcl(register struct ctype *tp) +static void listdcl(register struct ctype *tp) { do { register struct ctype *new; @@ -138,11 +138,10 @@ static unsigned char listdcl(register struct ctype *tp) yytext); } else if (new->type == FTN && yytoken == '{') { compound(); - return 0; + return; } } while (accept(',')); - - return 1; + expect(';'); } unsigned char decl(void) @@ -151,21 +150,21 @@ unsigned char decl(void) if (accept(';')) return 1; - tp = newctype(); + tp = newctype(); if (!spec(tp)) { if (curctx != OUTER_CTX) return 0; warning("data definition has no type or storage class"); } - if (yytoken == ';') { + if (accept(';')) { warning_error(options.useless, "useless type name in empty declaration"); - } else if (listdcl(tp)) { /* in case of not being a function */ - expect(';'); + } else { + listdcl(tp); } - delctype(tp); + return 1; }