Prevent the following code from compiling: enum color {RED, GREEN, BLUE}; enum rgb {RED, G, B};
Unified · Split
| @@ -2786,6 +2786,10 @@ static void struct_decl(CType *type, int u, int tdef) · 2785 unmodified lines | ||
| 2786 | 2786 | v = tok; |
| 2787 | 2787 | if (v < TOK_UIDENT) |
| 2788 | 2788 | expect("identifier"); |
| 2789 | + ss = sym_find(v); | |
| 2790 | + if (ss) | |
| 2791 | + tcc_error("redefinition of enumerator '%s'", | |
| 2792 | + get_tok_str(v, NULL)); | |
| 2789 | 2793 | next(); |
| 2790 | 2794 | if (tok == '=') { |
| 2791 | 2795 | next(); |