commit df87966673d742ff64cdb500a30f49ee69718120
Author:     Roberto E. Vargas Caballero <[email protected]>
AuthorDate: Sat Jul 18 18:38:19 2015 +0200
Commit:     Roberto E. Vargas Caballero <[email protected]>
CommitDate: Sat Jul 18 18:38:19 2015 +0200

    Make simpler conditions in popctx()

diff --git a/cc1/symbol.c b/cc1/symbol.c
index 6e4fdb7..c8b3487 100644
--- 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;

Reply via email to