scc

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

commit 31704f8d6cf7fe145c2e7c0109f46bf9a175bd21
parent da310fbe77b3276fa9554b91c3e28dd53399fe22
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 11 Aug 2015 16:11:26 +0200

Fix labelled statements

After a label was allowed only an expression, but the C grammar
allows any statement.

Diffstat:
Mcc1/stmt.c | 14++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/cc1/stmt.c b/cc1/stmt.c @@ -43,16 +43,14 @@ label(void) static void stmtexp(Symbol *lbreak, Symbol *lcont, Caselist *lswitch) { - Node *np; - - if (ahead() == ':') + if (accept(';')) + return; + if (ahead() == ':') { label(); - - if (yytoken != ';') { - np = expr(); - emit(OEXPR, np); + stmt(lbreak, lcont, lswitch); + return; } - + emit(OEXPR, expr()); expect(';'); }