Report error when redefining enumerator

Prevent the following code from compiling:

enum color {RED, GREEN, BLUE};
enum rgb {RED, G, B};
This commit is contained in:
Thomas Preud'homme 2013-09-20 22:49:49 +02:00
parent 82969f045c
commit 673befd2d7

View File

@ -2786,6 +2786,10 @@ static void struct_decl(CType *type, int u, int tdef)
v = tok;
if (v < TOK_UIDENT)
expect("identifier");
ss = sym_find(v);
if (ss)
tcc_error("redefinition of enumerator '%s'",
get_tok_str(v, NULL));
next();
if (tok == '=') {
next();