scc

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

commit d1e3fef8d6f06929405d377a1cb39eca367da123
parent 7d00111f794d7d658e9faeacdc136b2b28f80461
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 21 Aug 2012 22:28:05 +0200

Reducing scope of variables in asign

This helps to the compiler in order to generate a good code.

Diffstat:
expr.c | 31++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/expr.c b/expr.c @@ -298,28 +298,29 @@ cond(void) static struct node * assign(void) { - register unsigned char op; - register struct node *np; + register struct node *np = cond(); - np = cond(); for (;;) { + register unsigned char op; + switch (yytoken) { - case '=': op = OASSIGN; break; - case MUL_EQ: op = OA_MUL; break; - case DIV_EQ: op = OA_DIV; break; - case MOD_EQ: op = OA_MOD; break; - case ADD_EQ: op = OA_ADD; break; - case SUB_EQ: op = OA_SUB; break; - case SHL_EQ: op = OA_SHL; break; - case SHR_EQ: op = OA_SHR; break; - case AND_EQ: op = OA_AND; break; - case XOR_EQ: op = OA_XOR; break; - case OR_EQ: op = OA_OR; break; - default: return np; + case '=': op = OASSIGN; break; + case MUL_EQ: op = OA_MUL; break; + case DIV_EQ: op = OA_DIV; break; + case MOD_EQ: op = OA_MOD; break; + case ADD_EQ: op = OA_ADD; break; + case SUB_EQ: op = OA_SUB; break; + case SHL_EQ: op = OA_SHL; break; + case SHR_EQ: op = OA_SHR; break; + case AND_EQ: op = OA_AND; break; + case XOR_EQ: op = OA_XOR; break; + case OR_EQ: op = OA_OR; break; + default: goto return_np; } next(); np = node2(op, np, assign()); } +return_np: return np; }