diff options
| author | gingerBill <bill@gingerbill.org> | 2019-12-15 11:41:21 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2019-12-15 11:41:21 +0000 |
| commit | 4ba579bc25ab2bbde370231d090588c237552c76 (patch) | |
| tree | f2fb2615250d719446848d98f0c0f5b55583bf28 /src/check_expr.cpp | |
| parent | 58d4d424c6db749c10d723844ec5a847243bee39 (diff) | |
Also allow #no_bounds_check on an expression #499
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 6e6db24d1..0ee604283 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -3052,7 +3052,7 @@ bool check_index_value(CheckerContext *c, bool open_range, Ast *index_value, i64 } if (operand.mode == Addressing_Constant && - (c->stmt_state_flags & StmtStateFlag_no_bounds_check) == 0) { + (c->state_flags & StateFlag_no_bounds_check) == 0) { BigInt i = exact_value_to_integer(operand.value).value_integer; if (i.neg) { gbString expr_str = expr_to_string(operand.expr); @@ -6974,6 +6974,24 @@ bool check_range(CheckerContext *c, Ast *node, Operand *x, Operand *y, ExactValu ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) { + u32 prev_state_flags = c->state_flags; + defer (c->state_flags = prev_state_flags); + if (node->state_flags != 0) { + u32 in = node->state_flags; + u32 out = c->state_flags; + + if (in & StateFlag_no_bounds_check) { + out |= StateFlag_no_bounds_check; + out &= ~StateFlag_bounds_check; + } else if (in & StateFlag_bounds_check) { + out |= StateFlag_bounds_check; + out &= ~StateFlag_no_bounds_check; + } + + c->state_flags = out; + } + + ExprKind kind = Expr_Stmt; o->mode = Addressing_Invalid; |