Check for division by/modulo by zero when parsing the /= and %= operators.
git-svn-id: svn://svn.cc65.org/cc65/trunk@3937 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -2843,6 +2843,14 @@ static void opeq (const GenDesc* Gen, ExprDesc* Expr)
|
|||||||
} else if (Gen->Func == g_sub) {
|
} else if (Gen->Func == g_sub) {
|
||||||
g_dec (flags | CF_CONST, Expr2.IVal);
|
g_dec (flags | CF_CONST, Expr2.IVal);
|
||||||
} else {
|
} else {
|
||||||
|
if (Expr2.IVal == 0) {
|
||||||
|
/* Check for div by zero/mod by zero */
|
||||||
|
if (Gen->Func == g_div) {
|
||||||
|
Error ("Division by zero");
|
||||||
|
} else if (Gen->Func == g_mod) {
|
||||||
|
Error ("Modulo operation with zero");
|
||||||
|
}
|
||||||
|
}
|
||||||
Gen->Func (flags | CF_CONST, Expr2.IVal);
|
Gen->Func (flags | CF_CONST, Expr2.IVal);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user