mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-31 03:40:08 +00:00
Disable non-comparison operations for enum (use bit_set for flags)
This commit is contained in:
+1
-1
@@ -253,7 +253,7 @@ void check_type_decl(CheckerContext *ctx, Entity *e, Ast *type_expr, Type *def)
|
||||
if (decl->is_using) {
|
||||
// NOTE(bill): Must be an enum declaration
|
||||
if (te->kind == Ast_EnumType) {
|
||||
Scope *parent = ctx->scope->parent;
|
||||
Scope *parent = e->scope;
|
||||
if (parent->flags&ScopeFlag_File) {
|
||||
// NOTE(bill): Use package scope
|
||||
parent = parent->parent;
|
||||
|
||||
+10
-12
@@ -659,42 +659,40 @@ bool is_type_named_alias(Type *t) {
|
||||
}
|
||||
|
||||
bool is_type_boolean(Type *t) {
|
||||
t = core_type(t);
|
||||
// t = core_type(t);
|
||||
t = base_type(t);
|
||||
if (t->kind == Type_Basic) {
|
||||
return (t->Basic.flags & BasicFlag_Boolean) != 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool is_type_integer(Type *t) {
|
||||
t = core_type(t);
|
||||
// t = core_type(t);
|
||||
t = base_type(t);
|
||||
if (t->kind == Type_Basic) {
|
||||
return (t->Basic.flags & BasicFlag_Integer) != 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool is_type_unsigned(Type *t) {
|
||||
t = core_type(t);
|
||||
t = base_type(t);
|
||||
// t = core_type(t);
|
||||
if (t->kind == Type_Basic) {
|
||||
return (t->Basic.flags & BasicFlag_Unsigned) != 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool is_type_rune(Type *t) {
|
||||
t = core_type(t);
|
||||
// t = core_type(t);
|
||||
t = base_type(t);
|
||||
if (t->kind == Type_Basic) {
|
||||
return (t->Basic.flags & BasicFlag_Rune) != 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool is_type_number(Type *t) {
|
||||
t = core_type(t);
|
||||
if (t->kind == Type_Basic) {
|
||||
return (t->Basic.flags & BasicFlag_Numeric) != 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool is_type_numeric(Type *t) {
|
||||
t = core_type(t);
|
||||
// t = core_type(t);
|
||||
t = base_type(t);
|
||||
if (t->kind == Type_Basic) {
|
||||
return (t->Basic.flags & BasicFlag_Numeric) != 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user