aboutsummaryrefslogtreecommitdiff
path: root/src/check_type.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-01-03 12:51:32 +0000
committergingerBill <bill@gingerbill.org>2022-01-03 12:51:32 +0000
commit236b08cb4921d5c6000d5029f2936271acb45f29 (patch)
tree1d52a7412f97b2bb2aad909ccbc89513df72c401 /src/check_type.cpp
parente4f28de3de7b8bd72c89b87884302bfc7f943b4f (diff)
Fix #1356
Diffstat (limited to 'src/check_type.cpp')
-rw-r--r--src/check_type.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp
index b4f30d2f0..282da4d0a 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -922,20 +922,19 @@ void check_bit_set_type(CheckerContext *c, Type *type, Type *named_type, Ast *no
i64 lower = big_int_to_i64(&i);
i64 upper = big_int_to_i64(&j);
- bool lower_changed = false;
+ i64 actual_lower = lower;
i64 bits = MAX_BITS;
if (type->BitSet.underlying != nullptr) {
bits = 8*type_size_of(type->BitSet.underlying);
if (lower > 0) {
- lower = 0;
- lower_changed = true;
+ actual_lower = 0;
} else if (lower < 0) {
error(bs->elem, "bit_set does not allow a negative lower bound (%lld) when an underlying type is set", lower);
}
}
- i64 bits_required = upper-lower;
+ i64 bits_required = upper-actual_lower;
switch (be->op.kind) {
case Token_Ellipsis:
case Token_RangeFull:
@@ -959,7 +958,7 @@ void check_bit_set_type(CheckerContext *c, Type *type, Type *named_type, Ast *no
break;
}
if (!is_valid) {
- if (lower_changed) {
+ if (actual_lower != lower) {
error(bs->elem, "bit_set range is greater than %lld bits, %lld bits are required (internal the lower changed was changed 0 as an underlying type was set)", bits, bits_required);
} else {
error(bs->elem, "bit_set range is greater than %lld bits, %lld bits are required", bits, bits_required);