History

Report error when redefining enumerator

Prevent the following code from compiling: enum color {RED, GREEN, BLUE}; enum rgb {RED, G, B};

Thomas Preud'homme committed 13 years ago

Commit 673befd1 parent 82969f01 file · +4 −0Browse files

Unified · Split

tccgen.c+4−0
@@ -2786,6 +2786,10 @@ static void struct_decl(CType *type, int u, int tdef) · 2785 unmodified lines
27862786 v = tok;
27872787 if (v < TOK_UIDENT)
27882788 expect("identifier");
2789+ ss = sym_find(v);
2790+ if (ss)
2791+ tcc_error("redefinition of enumerator '%s'",
2792+ get_tok_str(v, NULL));
27892793 next();
27902794 if (tok == '=') {
27912795 next();

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t