[hackers] [scc] Make simpler conditions in popctx() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Sat, 18 Jul 2015 18:41:14 +0200 (CEST)

commit df87966673d742ff64cdb500a30f49ee69718120
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Sat Jul 18 18:38:19 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
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
_AT_@ -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;
Received on Sat Jul 18 2015 - 18:41:14 CEST

This archive was generated by hypermail 2.3.0 : Sat Jul 18 2015 - 18:48:14 CEST