scc

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

commit 87f8ea372e925ddb1ab531130bfd3e989e73c5b5
parent 814d466b8deea3209cb4178a3862eb803defca72
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 24 Apr 2014 18:29:11 +0200

Add else clause in if statements

Diffstat:
Mstmt.c | 11+++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/stmt.c b/stmt.c @@ -263,19 +263,22 @@ Default(Symbol *lbreak, Symbol *lcont, Caselist *lswitch) static void If(Symbol *lbreak, Symbol *lcont, Caselist *lswitch) { - Symbol *end = label(NULL, 1); + Symbol *end, *lelse = label(NULL, 1); Node *np; expect(IF); np = condition(); NEGATE(np, 1); - emitjump(end, np); + emitjump(lelse, np); stmt(lbreak, lcont, lswitch); if (accept(ELSE)) { - emitlabel(end); + end = label(NULL, 1); + emitjump(end, NULL); + emitlabel(lelse); stmt(lbreak, lcont, lswitch); - } else { emitlabel(end); + } else { + emitlabel(lelse); } }