diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2022-08-11 10:58:58 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-11 10:58:58 +0100 |
| commit | 8b007ad55aa5cb1a4f260f947c33e2f95fe7047b (patch) | |
| tree | 39f28ac711f62c2140dd633a83664f251214a86f /src/check_expr.cpp | |
| parent | 4ee50c5a35310eb48f0d6adf6a5c803fe044356e (diff) | |
| parent | 57dd5ec4db2a8d4ea40a605a885e6a432d3ec568 (diff) | |
Merge pull request #1943 from jaspergeer/fix-untyped-const-shift
fix #1840 invalid LLVM code gen for arithmetics between f32 and shifted untyped integer
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index b2f3567ba..f6c94466b 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -2505,8 +2505,17 @@ void check_shift(CheckerContext *c, Operand *x, Operand *y, Ast *node, Type *typ x->expr->tav.is_lhs = true; } x->mode = Addressing_Value; - if (type_hint && is_type_integer(type_hint)) { - x->type = type_hint; + if (type_hint) { + if (is_type_integer(type_hint)) { + x->type = type_hint; + } else { + gbString x_str = expr_to_string(x->expr); + gbString to_type = type_to_string(type_hint); + error(node, "Conversion of shifted operand '%s' to '%s' is not allowed", x_str, to_type); + gb_string_free(x_str); + gb_string_free(to_type); + x->mode = Addressing_Invalid; + } } // x->value = x_val; return; @@ -2522,7 +2531,7 @@ void check_shift(CheckerContext *c, Operand *x, Operand *y, Ast *node, Type *typ // TODO(bill): Should we support shifts for fixed arrays and #simd vectors? if (!is_type_integer(x->type)) { - gbString err_str = expr_to_string(y->expr); + gbString err_str = expr_to_string(x->expr); error(node, "Shift operand '%s' must be an integer", err_str); gb_string_free(err_str); x->mode = Addressing_Invalid; |