commit 2a651a1e594d8805e6873e45a72aa73ddb6bb505
parent 2abdf1c09b5cb1217625acdefaa8de44fe1aa15d
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Thu, 10 Jul 2014 14:43:40 +0200
Free labels in context()
We know that labels only can be deleted at the end of functions, but
context is also called in compound statements. Ths solution is
check the current context and deleted labels inly in context 0.
Diffstat:
3 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/cc1/cc1.h b/cc1/cc1.h
@@ -89,9 +89,6 @@ struct symbol {
struct symbol *hash;
};
-
-extern void freesyms(uint8_t ns);
-
extern Type *qualifier(Type *tp, uint8_t qlf),
*ctype(int8_t type, int8_t sign, int8_t size),
*mktype(Type *tp, uint8_t op, uint16_t nelem);
diff --git a/cc1/decl.c b/cc1/decl.c
@@ -477,7 +477,6 @@ extdecl(void)
emitsframe(sym);
context(NULL, NULL, NULL);
emiteframe();
- freesyms(NS_LABEL);
return;
}
} while (accept(','));
diff --git a/cc1/symbol.c b/cc1/symbol.c
@@ -27,7 +27,7 @@ hash(register const char *s)
return h & NR_SYM_HASH - 1;
}
-void
+static void
freesyms(uint8_t ns)
{
static struct symtab *tbl;
@@ -66,6 +66,8 @@ context(Symbol *lbreak, Symbol *lcont, Caselist *lswitch)
--curctx;
freesyms(NS_IDEN);
freesyms(NS_TAG);
+ if (curctx == 0)
+ freesyms(NS_LABEL);
}
Symbol *