diff options
| author | gingerBill <bill@gingerbill.org> | 2017-11-15 21:25:16 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2017-11-15 21:25:16 +0000 |
| commit | e48346a9ee6debb722568b8356412559f34c9b60 (patch) | |
| tree | bc36aa416e763f32d53d1a1a71ac06818332e6b1 /src/check_expr.cpp | |
| parent | 9bd8bdaa5a91b6cd1562130e05dd421aef0eefc8 (diff) | |
Disable negation of unsigned constants (Issue: #145)
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 1ed657ec8..707baaaf7 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -1494,6 +1494,13 @@ void check_unary_expr(Checker *c, Operand *o, Token op, AstNode *node) { o->mode = Addressing_Invalid; return; } + if (op.kind == Token_Sub && is_type_unsigned(type)) { + gbString err_str = expr_to_string(node); + error(op, "A unsigned constant cannot be negated '%s'", err_str); + gb_string_free(err_str); + o->mode = Addressing_Invalid; + return; + } o->value = exact_unary_operator_value(op.kind, o->value, precision); |