scc

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

commit bb1cd7c8595651dabecee45fcad96d6d7f579de5
parent 26ff02d15aedb16bc16fda9a2943d75a8ae95c75
Author: Quentin Rameau <quinq@fifth.space>
Date:   Sat, 14 Jan 2017 18:35:16 +0100

[cc1] fix continue statement within for loop

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

diff --git a/cc1/stmt.c b/cc1/stmt.c @@ -92,12 +92,13 @@ While(Symbol *lbreak, Symbol *lcont, Switch *lswitch) static void For(Symbol *lbreak, Symbol *lcont, Switch *lswitch) { - Symbol *begin, *cond, *end; + Symbol *begin, *cond; Node *econd, *einc, *einit; begin = newlabel(); - end = newlabel(); + lcont = newlabel(); cond = newlabel(); + lbreak = newlabel(); expect(FOR); expect('('); @@ -110,15 +111,18 @@ For(Symbol *lbreak, Symbol *lcont, Switch *lswitch) emit(OEXPR, einit); emit(OJUMP, cond); + emit(OBLOOP, NULL); emit(OLABEL, begin); - stmt(end, begin, lswitch); + stmt(lbreak, lcont, lswitch); + emit(OLABEL, lcont); emit(OEXPR, einc); emit(OLABEL, cond); emit((econd) ? OBRANCH : OJUMP, begin); emit(OEXPR, econd); emit(OELOOP, NULL); - emit(OLABEL, end); + + emit(OLABEL, lbreak); } static void