Fixed #9920 (Tokenizer: The keyword is not replaced, leads to false positive)

This commit is contained in:
Daniel Marjamäki 2020-09-28 16:35:50 +02:00
parent 84b8f32fd4
commit fa42d8c49c
2 changed files with 3 additions and 1 deletions

View File

@ -7171,7 +7171,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%|&&|*|/|%|^") && !Token::Match(tok->previous(), "%num%|%char% %name% *"))
if (Token::Match(tok->next(), "%assign%|%or%|%oror%|&&|*|/|%|^") && !Token::Match(tok->previous(), "%num%|%char%|) %name% *"))
continue;
if (executableScopeLevel == 0 && Token::Match(tok, "%name% (")) {
const Token *start = tok;

View File

@ -6223,6 +6223,8 @@ private:
// #9324
ASSERT_EQUALS("void f ( const char * str ) { while ( * str == '!' || * str == '[' ) { } }",
tokenizeAndStringify("void f(const char *str) { while (*str=='!' or *str=='['){} }"));
// #9920
ASSERT_EQUALS("result = ch != s . end ( ) && * ch == ':' ;", tokenizeAndStringify("result = ch != s.end() and *ch == ':';", false, true, Settings::Native, "test.c"));
}
void simplifyCalculations() {