mirror of
https://github.com/mirror/tinycc.git
synced 2026-08-22 11:23:27 +08:00
Fix type compatiblity of enums and ints
an enum must be compatible with one or more integer type,
so adjust the test accordingly. That means the following
redeclarations should work:
enum e6 { E1 = -1, E0 };
void f3(enum e6);
void f3(int); // should work as int and e6 are compatible
while the following should not:
void f4(enum e6 e);
void f4(unsigned e); // should error as unsigned and e6 are incompatible
This commit is contained in:
4
tccgen.c
4
tccgen.c
@@ -3009,7 +3009,9 @@ static int compare_types(CType *type1, CType *type2, int unqualified)
|
||||
return (type1->ref == type2->ref);
|
||||
} else if (bt1 == VT_FUNC) {
|
||||
return is_compatible_func(type1, type2);
|
||||
} else if (IS_ENUM(type1->t) || IS_ENUM(type2->t)) {
|
||||
} else if (IS_ENUM(type1->t) && IS_ENUM(type2->t)) {
|
||||
/* If both are enums then they must be the same, if only one is then
|
||||
t1 and t2 must be equal, which was checked above already. */
|
||||
return type1->ref == type2->ref;
|
||||
} else {
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user