Don't shift by a negative value in TemplateSimplifier::simplifyNumericCalculations()

This commit is contained in:
PKEuS 2012-09-06 17:02:20 +02:00
parent a8cdd15738
commit e2bc381550
1 changed files with 2 additions and 2 deletions

View File

@ -743,9 +743,9 @@ bool TemplateSimplifier::simplifyNumericCalculations(Token *tok)
if (cop == '&' || cop == '|' || cop == '^')
result = MathLib::calculate(tok->str(), tok->strAt(2), cop);
else if (cop == '<') {
if (tok->previous()->str() != "<<") // Ensure that its not a shift operator as used for streams
if (tok->previous()->str() != "<<" && rightInt > 0) // Ensure that its not a shift operator as used for streams
result = MathLib::toString<MathLib::bigint>(leftInt << rightInt);
} else
} else if (rightInt > 0)
result = MathLib::toString<MathLib::bigint>(leftInt >> rightInt);
if (!result.empty()) {