Fixed #9324 (FP compareBoolExpressionWithInt - when using C++ and/or operator synonyms)
This commit is contained in:
parent
03ae0ccef3
commit
8c8952ae7c
|
@ -7059,7 +7059,7 @@ bool Tokenizer::simplifyCAlternativeTokens()
|
|||
if (cOpIt != cAlternativeTokens.end()) {
|
||||
if (!Token::Match(tok->previous(), "%name%|%num%|%char%|)|]|> %name% %name%|%num%|%char%|%op%|("))
|
||||
continue;
|
||||
if (Token::Match(tok->next(), "%assign%|%or%|%oror%|&&|*|/|%|^"))
|
||||
if (Token::Match(tok->next(), "%assign%|%or%|%oror%|&&|*|/|%|^") && !Token::Match(tok->previous(), "%num%|%char% %name% *"))
|
||||
continue;
|
||||
tok->str(cOpIt->second);
|
||||
ret = true;
|
||||
|
|
|
@ -6151,6 +6151,9 @@ private:
|
|||
ASSERT_EQUALS("void f ( struct S * s ) { x = s . and + 1 ; }", tokenizeAndStringify("void f(struct S *s) { x = s->and + 1; }", false, true, Settings::Native, "test.c"));
|
||||
// #8745
|
||||
ASSERT_EQUALS("void f ( ) { if ( x ) { or = 0 ; } }", tokenizeAndStringify("void f() { if (x) or = 0; }"));
|
||||
// #9324
|
||||
ASSERT_EQUALS("void f ( const char * str ) { while ( * str == '!' || * str == '[' ) { } }",
|
||||
tokenizeAndStringify("void f(const char *str) { while (*str=='!' or *str=='['){} }"));
|
||||
}
|
||||
|
||||
void simplifyCalculations() {
|
||||
|
|
Loading…
Reference in New Issue