Skip to content

Commit dedebb2

Browse files
committed
Update again
1 parent 30b69b9 commit dedebb2

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/cfront.c

+7-6
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,7 @@ int read_numeric_sconstant()
13651365
int eval_expression_imm(opcode_t op, int op1, int op2)
13661366
{
13671367
/* return immediate result */
1368-
int is_odd = 1;
1368+
int tmp = op2;
13691369
int res = 0;
13701370
switch (op) {
13711371
case OP_add:
@@ -1381,11 +1381,12 @@ int eval_expression_imm(opcode_t op, int op1, int op2)
13811381
res = op1 / op2;
13821382
break;
13831383
case OP_mod:
1384-
/* TODO: provide arithmetic & operation instead of '&=' */
1385-
is_odd &= op2;
1386-
if (is_odd == 0)
1387-
res = op1 & (op2 - 1);
1388-
else
1384+
/* TODO: provide arithmetic & operation instead of '&=' */
1385+
tmp &= (tmp - 1);
1386+
if ((op2 != 0) && (tmp == 0)) {
1387+
res = op1;
1388+
res &= (op2 - 1);
1389+
} else
13891390
res = op1 % op2;
13901391
break;
13911392
case OP_lshift:

0 commit comments

Comments
 (0)