Fixed #4931 (Wrong calculation for '2|0*0&2>>1+0%2*1')
This commit is contained in:
parent
1977a18a1e
commit
1bf547c716
|
@ -1074,7 +1074,8 @@ bool TemplateSimplifier::simplifyCalculations(Token *_tokens)
|
|||
}
|
||||
|
||||
if (tok->str() == "0") {
|
||||
if (Token::Match(tok->previous(), "[+-|] 0")) {
|
||||
if ((Token::Match(tok->previous(), "[+-] 0 %cop%|;") && isLowerThanMulDiv(tok->next())) ||
|
||||
(Token::Match(tok->previous(), "%or% 0 %cop%|;") && isLowerThanXor(tok->next()))) {
|
||||
tok = tok->previous();
|
||||
if (Token::Match(tok->tokAt(-4), "[;{}] %name% = %name% [+-|] 0 ;") &&
|
||||
tok->strAt(-3) == tok->previous()->str()) {
|
||||
|
|
|
@ -2097,6 +2097,7 @@ private:
|
|||
ASSERT_EQUALS("x ( 1 )", tok("x(9&&8%5%4/3)")); // #4931
|
||||
ASSERT_EQUALS("x ( 1 )", tok("x(2 && 2|5<<2%4)")); // #4931
|
||||
ASSERT_EQUALS("x ( -2 << 6 | 1 )", tok("x(1-3<<6|5/3)")); // #4931
|
||||
ASSERT_EQUALS("x ( 2 )", tok("x(2|0*0&2>>1+0%2*1)")); // #4931
|
||||
|
||||
// don't remove these spaces..
|
||||
ASSERT_EQUALS("new ( auto ) ( 4 ) ;", tok("new (auto)(4);"));
|
||||
|
|
Loading…
Reference in New Issue