Fixed another division by zero error in skslc

You'd think by now it would have occurred to me that mod is also a kind
of division.

BUG=skia:6087

Change-Id: I5128d09db94d06f10762ad5c23df32551c5e5855
Reviewed-on: https://skia-review.googlesource.com/6607
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
Ethan Nicholas 2017-01-05 10:44:25 -05:00 committed by Skia Commit-Bot
parent c55bc9a8dd
commit 2503ab6e92

View File

@ -882,7 +882,12 @@ std::unique_ptr<Expression> IRGenerator::constantFold(const Expression& left,
}
fErrors.error(right.fPosition, "division by zero");
return nullptr;
case Token::PERCENT: return RESULT(Int, %);
case Token::PERCENT:
if (rightVal) {
return RESULT(Int, %);
}
fErrors.error(right.fPosition, "division by zero");
return nullptr;
case Token::BITWISEAND: return RESULT(Int, &);
case Token::BITWISEOR: return RESULT(Int, |);
case Token::BITWISEXOR: return RESULT(Int, ^);