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