[hackers] [scc] Return typedef symbols in struct namespaces || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Sun, 10 Jan 2016 09:15:59 +0100 (CET)

commit 50c78edf22ceb0a91da49921f16d65baef94cdac
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Sat Jan 9 22:29:14 2016 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Sat Jan 9 22:29:14 2016 +0100

    Return typedef symbols in struct namespaces
    
    Typedef symbols are stored in NS_IDEN namespace, which is the
    default namespace of the lexer. When the definition of struct
    type is done, the lexer take the namespace of the struct, and
    it means that typedef symbols are not seen in such context,
    making impossible to declara fields with typedefed types.

diff --git a/cc1/symbol.c b/cc1/symbol.c
index 4db41df..8ca6d92 100644
--- a/cc1/symbol.c
+++ b/cc1/symbol.c
_AT_@ -243,8 +243,24 @@ lookup(int ns, char *name)
                 if (*t != c || strcmp(t, name))
                         continue;
                 sns = sym->ns;
- if (sns == NS_KEYWORD || sns == NS_CPP || sns == ns)
+ /*
+ * CPP namespace has a total priority over the another
+ * namespaces, because it is a previous pass,
+ * If we are looking in the CPP namespace,
+ * we don't want symbols related to keywords or types.
+ * When a lookup is done in a namespace associated
+ * to a struct we also want symbols of NS_IDEN which
+ * are typedef, because in other case we cannot declare
+ * fields of such types.
+ */
+ if (sns == NS_CPP || sns == ns)
                         return sym;
+ if (ns == NS_CPP)
+ continue;
+ if (sns == NS_KEYWORD ||
+ (sym->flags & ISTYPEDEF) && ns >= NS_STRUCTS) {
+ return sym;
+ }
         }
         return allocsym(ns, name);
 }
Received on Sun Jan 10 2016 - 09:15:59 CET

This archive was generated by hypermail 2.3.0 : Sun Jan 10 2016 - 09:24:17 CET