ref: 66915c0956d505bf60140ff48021c0725edfa02c
parent: e06b6e3d1bf6342fdcd2481868d1d93cbb9a5028
author: Roberto E. Vargas Caballero <[email protected]>
date: Thu Aug 13 05:43:58 EDT 2015
Fix install() Install() failed when we wanted install a symbol in a different namespace where it was looked, and it was not declared.
--- a/cc1/symbol.c
+++ b/cc1/symbol.c
@@ -247,13 +247,18 @@
install(unsigned ns, Symbol *sym)
{
if (sym->ctx == curctx) {
- if (sym->flags & ISDECLARED)
- return NULL;
- sym->flags |= ISDECLARED;
- } else {
- sym = linkhash(newsym(ns), sym->name);
+ if (sym->flags & ISDECLARED) {
+ if (ns == sym->ns)
+ return NULL;
+ } else {
+ sym->flags |= ISDECLARED;
+ sym->ns = ns;
+ goto assign_id;
+ }
}
+ sym = linkhash(newsym(ns), sym->name);
+assign_id:
if (sym->ns != NS_CPP)
sym->id = (curctx) ? ++localcnt : ++globalcnt;