ref: 50c78edf22ceb0a91da49921f16d65baef94cdac
parent: dda0df0e38cf6b53d4db9b8858ee2dc0e07acc7f
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sat Jan 9 17:29:14 EST 2016
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.
--- a/cc1/symbol.c
+++ b/cc1/symbol.c
@@ -243,8 +243,24 @@
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);
}