mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-02 12:48:14 +00:00
Remove dead keywords; Fix min and max for enum types
This commit is contained in:
+14
-2
@@ -759,6 +759,8 @@ void check_enum_type(CheckerContext *ctx, Type *enum_type, Type *named_type, Ast
|
|||||||
ExactValue iota = exact_value_i64(-1);
|
ExactValue iota = exact_value_i64(-1);
|
||||||
ExactValue min_value = exact_value_i64(0);
|
ExactValue min_value = exact_value_i64(0);
|
||||||
ExactValue max_value = exact_value_i64(0);
|
ExactValue max_value = exact_value_i64(0);
|
||||||
|
bool min_value_set = false;
|
||||||
|
bool max_value_set = false;
|
||||||
|
|
||||||
scope_reserve(ctx->scope, et->fields.count);
|
scope_reserve(ctx->scope, et->fields.count);
|
||||||
|
|
||||||
@@ -810,11 +812,21 @@ void check_enum_type(CheckerContext *ctx, Type *enum_type, Type *named_type, Ast
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compare_exact_values(Token_Gt, min_value, iota)) {
|
if (min_value_set) {
|
||||||
|
if (compare_exact_values(Token_Gt, min_value, iota)) {
|
||||||
|
min_value = iota;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
min_value = iota;
|
min_value = iota;
|
||||||
|
min_value_set = true;
|
||||||
}
|
}
|
||||||
if (compare_exact_values(Token_Lt, max_value, iota)) {
|
if (max_value_set) {
|
||||||
|
if (compare_exact_values(Token_Lt, max_value, iota)) {
|
||||||
|
max_value = iota;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
max_value = iota;
|
max_value = iota;
|
||||||
|
max_value_set = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity *e = alloc_entity_constant(ctx->scope, ident->Ident.token, constant_type, iota);
|
Entity *e = alloc_entity_constant(ctx->scope, ident->Ident.token, constant_type, iota);
|
||||||
|
|||||||
@@ -1223,7 +1223,6 @@ void fix_advance_to_next_stmt(AstFile *f) {
|
|||||||
case Token_return:
|
case Token_return:
|
||||||
case Token_switch:
|
case Token_switch:
|
||||||
case Token_defer:
|
case Token_defer:
|
||||||
case Token_asm:
|
|
||||||
case Token_using:
|
case Token_using:
|
||||||
|
|
||||||
case Token_break:
|
case Token_break:
|
||||||
|
|||||||
@@ -122,9 +122,6 @@ TOKEN_KIND(Token__KeywordBegin, ""), \
|
|||||||
TOKEN_KIND(Token_type_of, "type_of"), \
|
TOKEN_KIND(Token_type_of, "type_of"), \
|
||||||
TOKEN_KIND(Token_macro, "macro"), \
|
TOKEN_KIND(Token_macro, "macro"), \
|
||||||
TOKEN_KIND(Token_const, "const"), \
|
TOKEN_KIND(Token_const, "const"), \
|
||||||
TOKEN_KIND(Token_asm, "asm"), \
|
|
||||||
TOKEN_KIND(Token_yield, "yield"), \
|
|
||||||
TOKEN_KIND(Token_await, "await"), \
|
|
||||||
TOKEN_KIND(Token__KeywordEnd, ""), \
|
TOKEN_KIND(Token__KeywordEnd, ""), \
|
||||||
TOKEN_KIND(Token_Count, "")
|
TOKEN_KIND(Token_Count, "")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user