1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-16 13:31:16 +00:00

Warnings instead of errors for division-by-zero/modulo-with-zero in evaluation.

This commit is contained in:
acqn 2022-11-12 22:13:56 +08:00
parent cc177208b4
commit 9d693d2c80
2 changed files with 8 additions and 8 deletions

View File

@ -319,9 +319,9 @@ static void OpAssignBitField (const GenDesc* Gen, ExprDesc* Expr, const char* Op
if (Expr2.IVal == 0) { if (Expr2.IVal == 0) {
/* Check for div by zero/mod by zero */ /* Check for div by zero/mod by zero */
if (Gen->Func == g_div) { if (Gen->Func == g_div) {
Error ("Division by zero"); Warning ("Division by zero");
} else if (Gen->Func == g_mod) { } else if (Gen->Func == g_mod) {
Error ("Modulo operation with zero"); Warning ("Modulo operation with zero");
} }
} else if (Gen->Func == g_asl || Gen->Func == g_asr) { } else if (Gen->Func == g_asl || Gen->Func == g_asr) {
const Type* CalType = IntPromotion (Expr->Type); const Type* CalType = IntPromotion (Expr->Type);
@ -528,9 +528,9 @@ static void OpAssignArithmetic (const GenDesc* Gen, ExprDesc* Expr, const char*
if (Expr2.IVal == 0 && !ED_IsUneval (Expr)) { if (Expr2.IVal == 0 && !ED_IsUneval (Expr)) {
/* Check for div by zero/mod by zero */ /* Check for div by zero/mod by zero */
if (Gen->Func == g_div) { if (Gen->Func == g_div) {
Error ("Division by zero"); Warning ("Division by zero");
} else if (Gen->Func == g_mod) { } else if (Gen->Func == g_mod) {
Error ("Modulo operation with zero"); Warning ("Modulo operation with zero");
} }
} else if (Gen->Func == g_asl || Gen->Func == g_asr) { } else if (Gen->Func == g_asl || Gen->Func == g_asr) {
const Type* CalType = IntPromotion (Expr->Type); const Type* CalType = IntPromotion (Expr->Type);

View File

@ -2204,7 +2204,7 @@ static void hie_internal (const GenDesc* Ops, /* List of generators */
case TOK_DIV: case TOK_DIV:
if (Val2 == 0) { if (Val2 == 0) {
if (!ED_IsUneval (Expr)) { if (!ED_IsUneval (Expr)) {
Error ("Division by zero"); Warning ("Division by zero");
} }
Expr->IVal = 0xFFFFFFFF; Expr->IVal = 0xFFFFFFFF;
} else { } else {
@ -2219,7 +2219,7 @@ static void hie_internal (const GenDesc* Ops, /* List of generators */
case TOK_MOD: case TOK_MOD:
if (Val2 == 0) { if (Val2 == 0) {
if (!ED_IsUneval (Expr)) { if (!ED_IsUneval (Expr)) {
Error ("Modulo operation with zero"); Warning ("Modulo operation with zero");
} }
Expr->IVal = 0; Expr->IVal = 0;
} else { } else {
@ -2291,9 +2291,9 @@ static void hie_internal (const GenDesc* Ops, /* List of generators */
rtype |= CF_CONST; rtype |= CF_CONST;
if (Expr2.IVal == 0 && !ED_IsUneval (Expr)) { if (Expr2.IVal == 0 && !ED_IsUneval (Expr)) {
if (Tok == TOK_DIV) { if (Tok == TOK_DIV) {
Error ("Division by zero"); Warning ("Division by zero");
} else if (Tok == TOK_MOD) { } else if (Tok == TOK_MOD) {
Error ("Modulo operation with zero"); Warning ("Modulo operation with zero");
} }
} }
if ((Gen->Flags & GEN_NOPUSH) != 0) { if ((Gen->Flags & GEN_NOPUSH) != 0) {