Fixed #1714 (Wrong precedence for shift operators when simplifying calculations?)
This commit is contained in:
parent
b702b8542d
commit
d09e1df0d7
|
@ -5783,7 +5783,7 @@ bool Tokenizer::simplifyCalculations()
|
||||||
// (1-2)
|
// (1-2)
|
||||||
while (Token::Match(tok, "[[,(=<>+-*] %num% [+-*/] %num% [],);=<>+-*/]") ||
|
while (Token::Match(tok, "[[,(=<>+-*] %num% [+-*/] %num% [],);=<>+-*/]") ||
|
||||||
Token::Match(tok, "<< %num% [+-*/] %num% [],);=<>+-*/]") ||
|
Token::Match(tok, "<< %num% [+-*/] %num% [],);=<>+-*/]") ||
|
||||||
Token::Match(tok, "[[,(=<>+-*] %num% [+-*/] %num% <<") ||
|
Token::Match(tok, "[[,(=<>+-*] %num% [+-*/] %num% <<|>>") ||
|
||||||
Token::Match(tok, "<< %num% [+-*/] %num% <<"))
|
Token::Match(tok, "<< %num% [+-*/] %num% <<"))
|
||||||
{
|
{
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
|
@ -5884,7 +5884,7 @@ bool Tokenizer::simplifyCalculations()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Token::Match(tok, "%num% <<|>> %num%"))
|
if (Token::Match(tok->previous(), "[([,=] %num% <<|>> %num%"))
|
||||||
{
|
{
|
||||||
const int op1(MathLib::toLongNumber(tok->str()));
|
const int op1(MathLib::toLongNumber(tok->str()));
|
||||||
const int op2(MathLib::toLongNumber(tok->tokAt(2)->str()));
|
const int op2(MathLib::toLongNumber(tok->tokAt(2)->str()));
|
||||||
|
|
|
@ -2294,6 +2294,9 @@ private:
|
||||||
ASSERT_EQUALS("int a [ 8 ] ;", tok("int a[5+6/2];"));
|
ASSERT_EQUALS("int a [ 8 ] ;", tok("int a[5+6/2];"));
|
||||||
ASSERT_EQUALS("int a [ 4 ] ;", tok("int a[(10)-1-5];"));
|
ASSERT_EQUALS("int a [ 4 ] ;", tok("int a[(10)-1-5];"));
|
||||||
ASSERT_EQUALS("int a [ i - 9 ] ;", tok("int a[i - 10 + 1];"));
|
ASSERT_EQUALS("int a [ i - 9 ] ;", tok("int a[i - 10 + 1];"));
|
||||||
|
|
||||||
|
ASSERT_EQUALS("x = 501 ;", tok("x = 1000 + 2 >> 1;"));
|
||||||
|
ASSERT_EQUALS("x = 125 ;", tok("x = 1000 / 2 >> 2;"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue