commit df87966673d742ff64cdb500a30f49ee69718120
parent 4eda2c207ed04ee707ff37e1a87ddd73d1c4d180
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Sat, 18 Jul 2015 18:38:19 +0200
Make simpler conditions in popctx()
Diffstat:
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/cc1/symbol.c b/cc1/symbol.c
@@ -57,22 +57,35 @@ pushctx(void)
void
popctx(void)
{
- Symbol *next, dummy = {.next = NULL}, *hp = &dummy, *sym;
+ Symbol *next, *sym;
+ Symbol dummy = {.next = NULL}, *hp = &dummy;
if (--curctx == 0)
localcnt = 0;
for (sym = head; sym && sym->ctx > curctx; sym = next) {
next = sym->next;
- if (sym->ns == NS_CPP || sym->ns == NS_LABEL && curctx != 0) {
+ switch (sym->ns) {
+ case NS_LABEL:
+ if (curctx != 0)
+ goto save_symbol;
+ if (sym->flags & ISDEFINED)
+ break;
+ /* TODO: check if the label was used */
+ printerr("label '%s' is not defined", sym->name);
+ break;
+ case NS_CPP:
+ save_symbol:
+ /*
+ * CPP symbols have file scope
+ * Labels have function scope
+ */
hp->next = sym;
hp = sym;
continue;
- } else if (sym->ns == NS_LABEL && !(sym->flags & ISDEFINED)) {
- /* FIXME: don't recover in this point */
- error("label '%s' is not defined", sym->name);
- } else if (sym->ns == NS_TAG) {
+ case NS_TAG:
sym->type->defined = 0;
+ break;
}
if (sym->hash)
htab[hash(sym->name)] = sym->hash;