scc

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

commit 4ed32812fd0a83d1bd86fb41f5c4531a6c477148
parent 4cf972513cefeba94d92337eed301e1f140582cf
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed,  3 Jul 2013 15:15:34 +0200

Fix del_ctx function

del_ctx must decrement the context number after deleting the symbols
of the context, because in other case the condition of the loop is not
working fine. We can not delete the symbols in del_ctx because they are
used in the parsing tree, but we must free them in some moment, so
after printing the tree is a good moment.

Diffstat:
decl.c | 1+
symbol.c | 2+-
2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/decl.c b/decl.c @@ -149,6 +149,7 @@ listdcl(register struct ctype *tp) struct node *np = compound(); prtree(np); putchar('\n'); + freesyms(); return; } } while (accept(',')); diff --git a/symbol.c b/symbol.c @@ -36,7 +36,6 @@ del_ctx(void) register struct symbol *sym, *next; static char *s; - --curctx; for (sym = head; sym; sym = next) { if (sym->ctx <= curctx) break; @@ -46,6 +45,7 @@ del_ctx(void) sym->next = headfun; headfun = sym; } + --curctx; } void