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:
parent
c4dac550a8
commit
4dd9c523e7
1 changed files with 15 additions and 7 deletions
|
@ -2843,6 +2843,14 @@ static void opeq (const GenDesc* Gen, ExprDesc* Expr)
|
|||
} else if (Gen->Func == g_sub) {
|
||||
g_dec (flags | CF_CONST, Expr2.IVal);
|
||||
} 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);
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue