From a5e42a046531405e0b8830ae092470c2aa2e67a8 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 26 Oct 2019 14:36:28 +0100 Subject: Add `ranged_fields_for_array_compound_literals` --- src/check_expr.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/check_expr.cpp') diff --git a/src/check_expr.cpp b/src/check_expr.cpp index f07ebe09c..7491094c8 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -7205,10 +7205,13 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type i64 lo = exact_value_to_i64(x.value); i64 hi = exact_value_to_i64(y.value); + i64 max_index = hi; if (op.kind == Token_RangeHalf) { hi -= 1; } - i64 max_index = hi; + if (op.kind == Token_Ellipsis) { + max_index += 1; + } bool new_range = range_cache_add_range(&rc, lo, hi); if (!new_range) { @@ -7257,8 +7260,8 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type continue; } - if (max < index) { - max = index; + if (max < index+1) { + max = index+1; } Operand operand = {}; -- cgit v1.2.3