Add %% operator (divisor modulo)

This commit is contained in:
Ginger Bill
2017-05-09 16:21:31 +01:00
parent 8677c81da7
commit c6d531df95
5 changed files with 21 additions and 1 deletions
+4
View File
@@ -1864,8 +1864,10 @@ bool check_binary_op(Checker *c, Operand *o, Token op) {
break;
case Token_Mod:
case Token_ModMod:
case Token_AndNot:
case Token_ModEq:
case Token_ModModEq:
case Token_AndNotEq:
if (!is_type_integer(type)) {
error(op, "Operator `%.*s` is only allowed with integers", LIT(op.string));
@@ -2669,8 +2671,10 @@ void check_binary_expr(Checker *c, Operand *x, AstNode *node) {
switch (op.kind) {
case Token_Quo:
case Token_Mod:
case Token_ModMod:
case Token_QuoEq:
case Token_ModEq:
case Token_ModModEq:
if ((x->mode == Addressing_Constant || is_type_integer(x->type)) &&
y->mode == Addressing_Constant) {
bool fail = false;