diff options
| author | gingerBill <bill@gingerbill.org> | 2021-08-13 14:17:27 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-08-13 14:17:27 +0100 |
| commit | 0e84e067562c490387cd221eccf3e26e14d09df5 (patch) | |
| tree | a23331e7504949d5ae7f9f5fec0663cb59c55f55 /src | |
| parent | e6b2df4b2be765cdf96a689a1353af549133d7ad (diff) | |
Fix lower and upper values for a `bit_set[Enum]` type.
Diffstat (limited to 'src')
| -rw-r--r-- | src/check_type.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp index a1b446ad2..ab3004320 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -986,8 +986,8 @@ void check_bit_set_type(CheckerContext *c, Type *type, Type *named_type, Ast *no error(bs->elem, "Enum type for bit_set must be an integer"); return; } - i64 lower = 0; - i64 upper = 0; + i64 lower = I64_MAX; + i64 upper = I64_MIN; for_array(i, et->Enum.fields) { Entity *e = et->Enum.fields[i]; @@ -1001,6 +1001,10 @@ void check_bit_set_type(CheckerContext *c, Type *type, Type *named_type, Ast *no lower = gb_min(lower, x); upper = gb_max(upper, x); } + if (et->Enum.fields.count == 0) { + lower = 0; + upper = 0; + } GB_ASSERT(lower <= upper); |