1
0
mirror of https://github.com/cc65/cc65.git synced 2024-09-30 08:57:49 +00:00

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:
uz 2009-02-17 21:09:59 +00:00
parent c4dac550a8
commit 4dd9c523e7

View File

@ -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 {