diff options
| -rw-r--r-- | scope.c | 6 | ||||
| -rw-r--r-- | symbol.c | 10 |
2 files changed, 9 insertions, 7 deletions
@@ -45,9 +45,9 @@ void start_file_scope(void) scope->next = &builtin_scope; file_scope = scope; - /* top-level stuff defaults to global, "static" will choose file scope */ - function_scope = global_scope; - block_scope = global_scope; + /* top-level stuff defaults to file scopt, "extern" etc will choose global scope */ + function_scope = scope; + block_scope = scope; } void start_symbol_scope(void) @@ -463,11 +463,13 @@ void bind_symbol(struct symbol *sym, struct ident *ident, enum namespace ns) scope = block_scope; if (ns == NS_SYMBOL && toplevel(scope)) { - sym->ctype.modifiers |= MOD_TOPLEVEL; - if (sym->ctype.modifiers & MOD_STATIC) + unsigned mod = MOD_ADDRESSABLE | MOD_TOPLEVEL; + scope = global_scope; + if (sym->ctype.modifiers & MOD_STATIC) { scope = file_scope; - else - sym->ctype.modifiers |= MOD_ADDRESSABLE; + mod = MOD_TOPLEVEL; + } + sym->ctype.modifiers |= mod; } if (ns == NS_MACRO) scope = file_scope; |
