Fixed #9324 (FP compareBoolExpressionWithInt - when using C++ and/or operator synonyms)

This commit is contained in:
Daniel Marjamäki 2019-11-03 12:53:30 +01:00
parent 03ae0ccef3
commit 8c8952ae7c
2 changed files with 4 additions and 1 deletions

View File

@ -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;

View File

@ -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() {