commit cd2811b5ff5949ed1c8b466225a77d7abc983b85
parent 3cc0b8d89bcfae1063191774c37c87e515fa2a31
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Sun, 22 Jan 2017 09:42:04 +0100
[cc1] Remove einit in For()
Decl() is emiting the initializer and it means that in some cases
the expression is emitted in the switch and in other cases
after the switch. It is profitable to have the invariant that
the expression is emitted in the switch for all the cases.
Diffstat:
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/cc1/stmt.c b/cc1/stmt.c
@@ -96,7 +96,7 @@ static void
For(Symbol *lbreak, Symbol *lcont, Switch *lswitch)
{
Symbol *begin, *cond;
- Node *econd, *einc, *einit = NULL;
+ Node *econd, *einc;
begin = newlabel();
lcont = newlabel();
@@ -115,7 +115,7 @@ For(Symbol *lbreak, Symbol *lcont, Switch *lswitch)
decl();
break;
default:
- einit = expr();
+ emit(OEXPR, expr());
case ';':
expect(';');
break;
@@ -125,7 +125,6 @@ For(Symbol *lbreak, Symbol *lcont, Switch *lswitch)
einc = (yytoken != ')') ? expr() : NULL;
expect(')');
- emit(OEXPR, einit);
emit(OJUMP, cond);
emit(OBLOOP, NULL);