Partial fix for #4931 (Wrong calculation of constants (simplifying: +,<<,% operations))
This commit is contained in:
parent
c0e33e20b4
commit
4abc0b7c1f
|
@ -4738,16 +4738,22 @@ bool Tokenizer::simplifyConditions()
|
|||
ret = true;
|
||||
}
|
||||
|
||||
if (Token::simpleMatch(tok, "( true &&") ||
|
||||
Token::simpleMatch(tok, "&& true &&") ||
|
||||
Token::simpleMatch(tok->next(), "&& true )")) {
|
||||
if (Token::simpleMatch(tok, "&& true &&")) {
|
||||
tok->deleteNext(2);
|
||||
ret = true;
|
||||
}
|
||||
|
||||
else if (Token::simpleMatch(tok, "( false ||") ||
|
||||
Token::simpleMatch(tok, "|| false ||") ||
|
||||
Token::simpleMatch(tok->next(), "|| false )")) {
|
||||
else if (Token::simpleMatch(tok, "|| false ||")) {
|
||||
tok->deleteNext(2);
|
||||
ret = true;
|
||||
}
|
||||
|
||||
else if (Token::Match(tok, "(|&& true && true &&|)")) {
|
||||
tok->deleteNext(2);
|
||||
ret = true;
|
||||
}
|
||||
|
||||
else if (Token::Match(tok, "%oror%|( false %oror% false %oror%|)")) {
|
||||
tok->deleteNext(2);
|
||||
ret = true;
|
||||
}
|
||||
|
|
|
@ -2653,6 +2653,15 @@ private:
|
|||
"}";
|
||||
ASSERT_EQUALS("void f ( int a ) { g ( ) ; }", tok(code));
|
||||
}
|
||||
|
||||
{
|
||||
// #4931
|
||||
const char code[] =
|
||||
"void f() {\n"
|
||||
"if (12 && 7) g();\n"
|
||||
"}";
|
||||
ASSERT_EQUALS("void f ( ) { g ( ) ; }", tok(code));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue