History

Allow local redefinition of enumerator

Thomas Preud'homme committed 12 years ago

Commit 3e565841 parent a620b124 files · +17 −2Browse files

Unified · Split

4 files
  1. tccgen.c +1 −1
  2. tests/tests2/63_local_enumerator_redefinition.c +14 −0
  3. tests/tests2/63_local_enumerator_redefinition.expect +0 −0
  4. tests/tests2/Makefile +2 −1
tccgen.c+1−1
@@ -2827,7 +2827,7 @@ static void struct_decl(CType *type, int u, int tdef) · 2826 unmodified lines
28272827 if (v < TOK_UIDENT)
28282828 expect("identifier");
28292829 ss = sym_find(v);
2830− if (ss)
2830+ if (ss && !local_stack)
28312831 tcc_error("redefinition of enumerator '%s'",
28322832 get_tok_str(v, NULL));
28332833 next();
tests/tests2/63_local_enumerator_redefinition.c+14−0
@@ -0,0 +1,14 @@
1+enum {
2+ FOO,
3+ BAR
4+};
5+
6+int main(void)
7+{
8+ enum {
9+ FOO = 2,
10+ BAR
11+ };
12+
13+ return BAR - FOO;
14+}
tests/tests2/63_local_enumerator_redefinition.expect+0−0

Empty file added.

tests/tests2/Makefile+2−1
@@ -74,7 +74,8 @@ TESTS = \ · 73 unmodified lines
7474 59_function_array.test \
7575 60_enum_redefinition.test \
7676 61_undefined_enum.test \
77− 62_enumerator_redefinition.test
77+ 62_enumerator_redefinition.test \
78+ 63_local_enumerator_redefinition.test
7879
7980 # 30_hanoi.test -- seg fault in the code, gcc as well
8081 # 34_array_assignment.test -- array assignment is not in C standard

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