| @@ -571,6 +571,14 @@ ST_INLN Sym *sym_find(int v) · 570 unmodified lines |
| 571 | return table_ident[v]->sym_identifier; | 571 | return table_ident[v]->sym_identifier; |
| 572 | } | 572 | } |
| 573 | | 573 | |
| | 574 | static int sym_scope(Sym *s) |
| | 575 | { |
| | 576 | if (IS_ENUM_VAL (s->type.t)) |
| | 577 | return s->type.ref->sym_scope; |
| | 578 | else |
| | 579 | return s->sym_scope; |
| | 580 | } |
| | 581 | |
| 574 | /* push a given symbol on the symbol stack */ | 582 | /* push a given symbol on the symbol stack */ |
| 575 | ST_FUNC Sym *sym_push(int v, CType *type, int r, int c) | 583 | ST_FUNC Sym *sym_push(int v, CType *type, int r, int c) |
| 576 | { | 584 | { |
| @@ -596,7 +604,7 @@ ST_FUNC Sym *sym_push(int v, CType *type, int r, int c) · 19 unmodified lines |
| 596 | s->prev_tok = *ps; | 604 | s->prev_tok = *ps; |
| 597 | *ps = s; | 605 | *ps = s; |
| 598 | s->sym_scope = local_scope; | 606 | s->sym_scope = local_scope; |
| 599 | if (s->prev_tok && s->prev_tok->sym_scope == s->sym_scope) | 607 | if (s->prev_tok && sym_scope(s->prev_tok) == s->sym_scope) |
| 600 | tcc_error("redeclaration of '%s'", | 608 | tcc_error("redeclaration of '%s'", |
| 601 | get_tok_str(v & ~SYM_STRUCT, NULL)); | 609 | get_tok_str(v & ~SYM_STRUCT, NULL)); |
| 602 | } | 610 | } |
| @@ -919,7 +927,7 @@ static void merge_attr(AttributeDef *ad, AttributeDef *ad1) · 316 unmodified lines |
| 919 | /* Merge some type attributes. */ | 927 | /* Merge some type attributes. */ |
| 920 | static void patch_type(Sym *sym, CType *type) | 928 | static void patch_type(Sym *sym, CType *type) |
| 921 | { | 929 | { |
| 922 | if (!(type->t & VT_EXTERN)) { | 930 | if (!(type->t & VT_EXTERN) || IS_ENUM_VAL(sym->type.t)) { |
| 923 | if (!(sym->type.t & VT_EXTERN)) | 931 | if (!(sym->type.t & VT_EXTERN)) |
| 924 | tcc_error("redefinition of '%s'", get_tok_str(sym->v, NULL)); | 932 | tcc_error("redefinition of '%s'", get_tok_str(sym->v, NULL)); |
| 925 | sym->type.t &= ~VT_EXTERN; | 933 | sym->type.t &= ~VT_EXTERN; |