aboutsummaryrefslogtreecommitdiff
path: root/src/check_type.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-08-15 15:44:41 +0100
committergingerBill <bill@gingerbill.org>2018-08-15 15:44:41 +0100
commitb3ebff715a2e483ed1210b7eea70d60a75ae8c3b (patch)
tree3e7b159d0c0366a23686f06419724e11daa33aaa /src/check_type.cpp
parent1ee60663bb9a6d3b5a5effb3028679928c77fa1a (diff)
Fix defer ir bug
Diffstat (limited to 'src/check_type.cpp')
-rw-r--r--src/check_type.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp
index f4b53c994..6b93fbd68 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -502,8 +502,8 @@ void check_enum_type(CheckerContext *ctx, Type *enum_type, Type *named_type, Ast
base_type = check_type(ctx, et->base_type);
}
- if (base_type == nullptr || !(is_type_integer(base_type) || is_type_float(base_type))) {
- error(node, "Base type for enumeration must be numeric");
+ if (base_type == nullptr || !is_type_integer(base_type)) {
+ error(node, "Base type for enumeration must be an integer");
return;
}
if (is_type_enum(base_type)) {
@@ -685,16 +685,16 @@ void check_bit_set_type(CheckerContext *ctx, Type *type, Ast *node) {
ast_node(bs, BitSetType, node);
GB_ASSERT(type->kind == Type_BitSet);
- Type *bt = check_type_expr(ctx, bs->base_type, nullptr);
+ Type *bt = check_type_expr(ctx, bs->base, nullptr);
- type->BitSet.base_type = bt;
+ type->BitSet.base = bt;
if (!is_type_enum(bt)) {
- error(bs->base_type, "Expected an enum type for a bit_set");
+ error(bs->base, "Expected an enum type for a bit_set");
} else {
Type *et = base_type(bt);
GB_ASSERT(et->kind == Type_Enum);
if (!is_type_integer(et->Enum.base_type)) {
- error(bs->base_type, "Enum type for bit_set must be an integer");
+ error(bs->base, "Enum type for bit_set must be an integer");
return;
}
i64 min_value = 0;
@@ -713,8 +713,10 @@ void check_bit_set_type(CheckerContext *ctx, Type *type, Ast *node) {
max_value = gb_max(max_value, x);
}
+ GB_ASSERT(min_value <= max_value);
+
if (max_value - min_value > 64) {
- error(bs->base_type, "bit_set range is greater than 64 bits");
+ error(bs->base, "bit_set range is greater than 64 bits");
}
type->BitSet.min = min_value;