Allow local redefinition of enumerator
This commit is contained in:
parent
a620b12dc1
commit
3e56584223
4 changed files with 17 additions and 2 deletions
2
tccgen.c
2
tccgen.c
|
|
@ -2827,7 +2827,7 @@ static void struct_decl(CType *type, int u, int tdef)
|
||||||
if (v < TOK_UIDENT)
|
if (v < TOK_UIDENT)
|
||||||
expect("identifier");
|
expect("identifier");
|
||||||
ss = sym_find(v);
|
ss = sym_find(v);
|
||||||
if (ss)
|
if (ss && !local_stack)
|
||||||
tcc_error("redefinition of enumerator '%s'",
|
tcc_error("redefinition of enumerator '%s'",
|
||||||
get_tok_str(v, NULL));
|
get_tok_str(v, NULL));
|
||||||
next();
|
next();
|
||||||
|
|
|
||||||
14
tests/tests2/63_local_enumerator_redefinition.c
Normal file
14
tests/tests2/63_local_enumerator_redefinition.c
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
enum {
|
||||||
|
FOO,
|
||||||
|
BAR
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
enum {
|
||||||
|
FOO = 2,
|
||||||
|
BAR
|
||||||
|
};
|
||||||
|
|
||||||
|
return BAR - FOO;
|
||||||
|
}
|
||||||
0
tests/tests2/63_local_enumerator_redefinition.expect
Normal file
0
tests/tests2/63_local_enumerator_redefinition.expect
Normal file
|
|
@ -74,7 +74,8 @@ TESTS = \
|
||||||
59_function_array.test \
|
59_function_array.test \
|
||||||
60_enum_redefinition.test \
|
60_enum_redefinition.test \
|
||||||
61_undefined_enum.test \
|
61_undefined_enum.test \
|
||||||
62_enumerator_redefinition.test
|
62_enumerator_redefinition.test \
|
||||||
|
63_local_enumerator_redefinition.test
|
||||||
|
|
||||||
# 30_hanoi.test -- seg fault in the code, gcc as well
|
# 30_hanoi.test -- seg fault in the code, gcc as well
|
||||||
# 34_array_assignment.test -- array assignment is not in C standard
|
# 34_array_assignment.test -- array assignment is not in C standard
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue