scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit 03f9a752d53b3b3f15344bd610b292393b5e13f2
parent e1ea759cef4ef3331b24d5fb90f28438a1df3070
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat, 30 Jun 2012 01:47:23 +0200

Fixed bug in functions declarations

After a function we don't have to expect a ;, because it will mark end of
declarations and expressions, and not a function body. It is necessary add a
return value for the function in order to can detect this condition, and in
this case avoid the expecting of ;.

Diffstat:
decl.c | 11++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/decl.c b/decl.c @@ -125,7 +125,7 @@ static void declarator(void) pushtype(*bp); } -static void listdcl(register struct ctype *cp) +static unsigned char listdcl(register struct ctype *cp) { register struct type *tp; @@ -138,9 +138,11 @@ static void listdcl(register struct ctype *cp) yytext); } else if (tp->op == FTN && yytoken == '{') { compound(); - return; + return 0; } } while (accept(',')); + + return 1; } unsigned char decl(void) @@ -158,10 +160,9 @@ unsigned char decl(void) if (yytoken == ';') { warning_error(user_opt.useless_typename, "useless type name in empty declaration"); - } else { - listdcl(&ctype); + } else if (listdcl(&ctype)) { /* in case of not being a function */ + expect(';'); } - expect(';'); return 1; }