diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-01-03 20:07:46 +0000 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-01-03 20:07:46 +0000 |
| commit | cff1b3dff6d169675309d3f7a8433ed55b9a2007 (patch) | |
| tree | ad144e56efead6456064261b086bdc3befaada50 /src/checker/expr.c | |
| parent | 883dd0642c377840e3baaca341ea147e53c2d2d5 (diff) | |
v0.0.5
Fix enumerations to so they work as integers in indices; Add llir_opt.c and llir_print.c
Diffstat (limited to 'src/checker/expr.c')
| -rw-r--r-- | src/checker/expr.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/checker/expr.c b/src/checker/expr.c index 5a200df6a..debbd883a 100644 --- a/src/checker/expr.c +++ b/src/checker/expr.c @@ -1019,7 +1019,8 @@ i64 check_array_count(Checker *c, AstNode *e) { } return 0; } - if (is_type_untyped(o.type) || is_type_integer(o.type)) { + Type *type = base_type(base_enum_type(o.type)); + if (is_type_untyped(type) || is_type_integer(type)) { if (o.value.kind == ExactValue_Integer) { i64 count = o.value.value_integer; if (count >= 0) { @@ -1655,7 +1656,7 @@ void check_shift(Checker *c, Operand *x, Operand *y, AstNode *node) { } bool x_is_untyped = is_type_untyped(x->type); - if (!(is_type_integer(x->type) || (x_is_untyped && x_val.kind == ExactValue_Integer))) { + if (!(is_type_integer(base_enum_type(x->type)) || (x_is_untyped && x_val.kind == ExactValue_Integer))) { gbString err_str = expr_to_string(x->expr); error_node(node, "Shifted operand `%s` must be an integer", err_str); gb_string_free(err_str); @@ -1663,7 +1664,7 @@ void check_shift(Checker *c, Operand *x, Operand *y, AstNode *node) { return; } - if (is_type_unsigned(y->type)) { + if (is_type_unsigned(base_enum_type(y->type))) { } else if (is_type_untyped(y->type)) { convert_to_typed(c, y, t_untyped_integer, 0); @@ -1700,7 +1701,7 @@ void check_shift(Checker *c, Operand *x, Operand *y, AstNode *node) { return; } - if (!is_type_integer(x->type)) { + if (!is_type_integer(base_enum_type(x->type))) { // NOTE(bill): It could be an untyped float but still representable // as an integer x->type = t_untyped_integer; @@ -1709,7 +1710,7 @@ void check_shift(Checker *c, Operand *x, Operand *y, AstNode *node) { x->value = exact_value_shift(be->op.kind, x_val, make_exact_value_integer(amount)); if (is_type_typed(x->type)) { - check_is_expressible(c, x, base_type(x->type)); + check_is_expressible(c, x, base_type(base_enum_type(x->type))); } return; } @@ -2416,7 +2417,7 @@ bool check_index_value(Checker *c, AstNode *index_value, i64 max_count, i64 *val return false; } - if (!is_type_integer(operand.type)) { + if (!is_type_integer(base_enum_type(operand.type))) { gbString expr_str = expr_to_string(operand.expr); error_node(operand.expr, "Index `%s` must be an integer", expr_str); gb_string_free(expr_str); |