| @@ -616,11 +616,12 @@ ST_FUNC Sym *global_identifier_push(int v, int t, int c) · 615 unmodified lines |
| 616 | 616 | { |
| 617 | 617 | Sym *s, **ps; |
| 618 | 618 | s = sym_push2(&global_stack, v, t, c); |
| 619 | + s->r = VT_CONST | VT_SYM; |
| 619 | 620 | /* don't record anonymous symbol */ |
| 620 | 621 | if (v < SYM_FIRST_ANOM) { |
| 621 | 622 | ps = &table_ident[v - TOK_IDENT]->sym_identifier; |
| 622 | | − /* modify the top most local identifier, so that |
| 623 | | − sym_identifier will point to 's' when popped */ |
| 623 | + /* modify the top most local identifier, so that sym_identifier will |
| 624 | + point to 's' when popped; happens when called from inline asm */ |
| 624 | 625 | while (*ps != NULL && (*ps)->sym_scope) |
| 625 | 626 | ps = &(*ps)->prev_tok; |
| 626 | 627 | s->prev_tok = *ps; |
| @@ -846,9 +847,8 @@ ST_FUNC Sym *get_sym_ref(CType *type, Section *sec, unsigned long offset, unsign · 219 unmodified lines |
| 846 | 847 | Sym *sym; |
| 847 | 848 | |
| 848 | 849 | v = anon_sym++; |
| 849 | | − sym = global_identifier_push(v, type->t | VT_STATIC, 0); |
| 850 | | − sym->type.ref = type->ref; |
| 851 | | − sym->r = VT_CONST | VT_SYM; |
| 850 | + sym = sym_push(v, type, VT_CONST | VT_SYM, 0); |
| 851 | + sym->type.t |= VT_STATIC; |
| 852 | 852 | put_extern_sym(sym, sec, offset, size); |
| 853 | 853 | return sym; |
| 854 | 854 | } |
| @@ -860,7 +860,7 @@ static void vpush_ref(CType *type, Section *sec, unsigned long offset, unsigned · 5 unmodified lines |
| 860 | 860 | } |
| 861 | 861 | |
| 862 | 862 | /* define a new external reference to a symbol 'v' of type 'u' */ |
| 863 | | −ST_FUNC Sym *external_global_sym(int v, CType *type, int r) |
| 863 | +ST_FUNC Sym *external_global_sym(int v, CType *type) |
| 864 | 864 | { |
| 865 | 865 | Sym *s; |
| 866 | 866 | |
| @@ -869,7 +869,6 @@ ST_FUNC Sym *external_global_sym(int v, CType *type, int r) · 2 unmodified lines |
| 869 | 869 | /* push forward reference */ |
| 870 | 870 | s = global_identifier_push(v, type->t | VT_EXTERN, 0); |
| 871 | 871 | s->type.ref = type->ref; |
| 872 | | − s->r = r | VT_CONST | VT_SYM; |
| 873 | 872 | } else if (IS_ASM_SYM(s)) { |
| 874 | 873 | s->type.t = type->t | (s->type.t & VT_EXTERN); |
| 875 | 874 | s->type.ref = type->ref; |
| @@ -1001,7 +1000,6 @@ static Sym *external_sym(int v, CType *type, int r, AttributeDef *ad) · 125 unmodified lines |
| 1001 | 1000 | tcc_error("conflicting types for '%s'", get_tok_str(s->v, NULL)); |
| 1002 | 1001 | /* push forward reference */ |
| 1003 | 1002 | s = sym_push(v, type, r | VT_CONST | VT_SYM, 0); |
| 1004 | | − s->type.t |= VT_EXTERN; |
| 1005 | 1003 | s->a = ad->a; |
| 1006 | 1004 | s->sym_scope = 0; |
| 1007 | 1005 | } else { |
| @@ -1018,7 +1016,7 @@ static Sym *external_sym(int v, CType *type, int r, AttributeDef *ad) · 10 unmodified lines |
| 1018 | 1016 | /* push a reference to global symbol v */ |
| 1019 | 1017 | ST_FUNC void vpush_global_sym(CType *type, int v) |
| 1020 | 1018 | { |
| 1021 | | − vpushsym(type, external_global_sym(v, type, 0)); |
| 1019 | + vpushsym(type, external_global_sym(v, type)); |
| 1022 | 1020 | } |
| 1023 | 1021 | |
| 1024 | 1022 | /* save registers up to (vtop - n) stack entry */ |
| @@ -3427,7 +3425,7 @@ redo: · 2402 unmodified lines |
| 3427 | 3425 | if (!s) { |
| 3428 | 3426 | tcc_warning("implicit declaration of function '%s'", |
| 3429 | 3427 | get_tok_str(tok, &tokc)); |
| 3430 | | − s = external_global_sym(tok, &func_old_type, 0); |
| 3428 | + s = external_global_sym(tok, &func_old_type); |
| 3431 | 3429 | } |
| 3432 | 3430 | ad->cleanup_func = s; |
| 3433 | 3431 | next(); |
| @@ -5258,7 +5256,7 @@ special_math_val: · 1824 unmodified lines |
| 5258 | 5256 | #endif |
| 5259 | 5257 | ) |
| 5260 | 5258 | tcc_warning("implicit declaration of function '%s'", name); |
| 5261 | | − s = external_global_sym(t, &func_old_type, 0); |
| 5259 | + s = external_global_sym(t, &func_old_type); |
| 5262 | 5260 | } |
| 5263 | 5261 | |
| 5264 | 5262 | r = s->r; |
| @@ -7265,8 +7263,8 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 2000 unmodified lines |
| 7265 | 7263 | put_extern_sym(sym, sec, addr, size); |
| 7266 | 7264 | } else { |
| 7267 | 7265 | /* push global reference */ |
| 7268 | | − sym = get_sym_ref(type, sec, addr, size); |
| 7269 | | − vpushsym(type, sym); |
| 7266 | + vpush_ref(type, sec, addr, size); |
| 7267 | + sym = vtop->sym; |
| 7270 | 7268 | vtop->r |= r; |
| 7271 | 7269 | } |
| 7272 | 7270 | |
| @@ -7556,14 +7554,12 @@ static int decl0(int l, int is_for_loop_init, Sym *func_sym) · 283 unmodified lines |
| 7556 | 7554 | type.t = (type.t & ~VT_EXTERN) | VT_STATIC; |
| 7557 | 7555 | |
| 7558 | 7556 | /* put function symbol */ |
| 7559 | | − sym = external_global_sym(v, &type, 0); |
| 7560 | | − type.t &= ~VT_EXTERN; |
| 7561 | | − patch_storage(sym, &ad, &type); |
| 7557 | + sym = external_sym(v, &type, 0, &ad); |
| 7562 | 7558 | |
| 7563 | 7559 | /* static inline functions are just recorded as a kind |
| 7564 | 7560 | of macro. Their code will be emitted at the end of |
| 7565 | 7561 | the compilation unit only if they are used */ |
| 7566 | | − if ((type.t & (VT_INLINE | VT_STATIC)) == |
| 7562 | + if ((type.t & (VT_INLINE | VT_STATIC)) == |
| 7567 | 7563 | (VT_INLINE | VT_STATIC)) { |
| 7568 | 7564 | struct InlineFunc *fn; |
| 7569 | 7565 | const char *filename; |