aboutsummaryrefslogtreecommitdiff
path: root/src/check_type.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-08-14 18:35:14 +0100
committergingerBill <bill@gingerbill.org>2018-08-14 18:35:14 +0100
commit79a3c0b36cdea0f2b5307f37b131926e2283cddf (patch)
tree4ad29094ebcecd17e15a1dec2d1a031147d02cac /src/check_type.cpp
parent966249c10a32425b408df5a5ea6085781f38b8a7 (diff)
Fix `bit_set` range
Diffstat (limited to 'src/check_type.cpp')
-rw-r--r--src/check_type.cpp18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp
index 34f08af3d..f4b53c994 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -708,24 +708,14 @@ void check_bit_set_type(CheckerContext *ctx, Type *type, Ast *node) {
}
ExactValue value = exact_value_to_integer(e->Constant.value);
GB_ASSERT(value.kind == ExactValue_Integer);
- BigInt v = value.value_integer;
-
-
- if (big_int_cmp(&v, &BIG_INT_ZERO) < 0) {
- error(bs->base_type, "Negative enum values are not allowed in a bit_set");
- return;
- }
-
- if (big_int_cmp(&v, &v64) >= 0) {
- error(bs->base_type, "Enum values overe 64 are not allowed in a bit_set");
- return;
- }
-
- i64 x = big_int_to_i64(&v);
+ i64 x = big_int_to_i64(&value.value_integer);
min_value = gb_min(min_value, x);
max_value = gb_max(max_value, x);
}
+ if (max_value - min_value > 64) {
+ error(bs->base_type, "bit_set range is greater than 64 bits");
+ }
type->BitSet.min = min_value;
type->BitSet.max = max_value;