scc

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

commit b054b416db6ea7150a34823cb898e45c42d5574c
parent 1cc0995ffaabe9f5abc298123ff591df5ca32ce0
Author: Roberto E. Vargas Caballero <roberto.vargas@igrid-td.com>
Date:   Mon, 11 Apr 2016 16:52:23 +0200

[cc2] Fix initialization of parser variables

Curfun cannot be cleaned in endfun(), because then we lost the
begin of the function for all the code generators. Inpars()
was not correctly set, so any function could be loaded.

Diffstat:
cc2/parser.c | 8+-------
1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/cc2/parser.c b/cc2/parser.c @@ -613,18 +613,13 @@ stmt(void) static void beginfun(void) { - inpars = 0; + inpars = 1; pushctx(); } static void endfun(void) { - Node *np; - - np = newnode(); - curfun = NULL; - inpars = 0; /* I know, it is a bit redundant */ endf = 1; } @@ -634,7 +629,6 @@ parse(void) cleannodes(); /* remove code of previous function */ popctx(); /* remove context of previous function */ curfun = NULL; - endf = 0; while (!endf && nextline()) /* nothing */;