aboutsummaryrefslogtreecommitdiff
path: root/src/check_type.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2019-05-28 12:45:20 +0100
committergingerBill <bill@gingerbill.org>2019-05-28 12:45:20 +0100
commit222941727f2b094449838135c3157120e0176e58 (patch)
tree6e3051341f1873873596594abfe02693aad4e6fc /src/check_type.cpp
parent5697d6df7466ef5f4e676f391c104ef165cadb6b (diff)
Add `..<` operator for ranges; Add extra checking for bit set assignments
Diffstat (limited to 'src/check_type.cpp')
-rw-r--r--src/check_type.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp
index e7eafad17..790cec789 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -1044,8 +1044,18 @@ void check_bit_set_type(CheckerContext *c, Type *type, Type *named_type, Ast *no
bits = 8*type_size_of(type->BitSet.underlying);
}
- if (upper - lower >= bits) {
- error(bs->elem, "bit_set range is greater than %lld bits, %lld bits are required", bits, (upper-lower+1));
+ switch (be->op.kind) {
+ case Token_Ellipsis:
+ if (upper - lower >= bits) {
+ error(bs->elem, "bit_set range is greater than %lld bits, %lld bits are required", bits, (upper-lower+1));
+ }
+ break;
+ case Token_RangeHalf:
+ if (upper - lower > bits) {
+ error(bs->elem, "bit_set range is greater than %lld bits, %lld bits are required", bits, (upper-lower));
+ }
+ upper -= 1;
+ break;
}
type->BitSet.elem = t;
type->BitSet.lower = lower;