diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 787a1fb67..30bd5eac5 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 1820d7d85..2779eda33 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -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() {