mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Disable negation of unsigned constants (Issue: #145)
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
// #import "fmt.odin";
|
|
||||||
// Multiple precision decimal numbers
|
// Multiple precision decimal numbers
|
||||||
// NOTE: This is only for floating point printing and nothing else
|
// NOTE: This is only for floating point printing and nothing else
|
||||||
|
|
||||||
|
|||||||
@@ -1494,6 +1494,13 @@ void check_unary_expr(Checker *c, Operand *o, Token op, AstNode *node) {
|
|||||||
o->mode = Addressing_Invalid;
|
o->mode = Addressing_Invalid;
|
||||||
return;
|
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);
|
o->value = exact_unary_operator_value(op.kind, o->value, precision);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user