diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index c0d2eb608..c3b3e75f4 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2799,7 +2799,7 @@ void Tokenizer::createLinks2() token->link(0); } - else if (token->str() == ";") + else if (Token::Match(token, "%oror%|&&|;")) while (!type.empty() && type.top()->str() == "<") type.pop(); else if (token->str() == "<" && token->previous() && token->previous()->isName() && !token->previous()->varId()) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index f632eee06..701a82031 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -7093,6 +7093,19 @@ private: ASSERT_EQUALS("", errout.str()); } + + { + // if (a < b || c > d) { } + const char code[] = "if (a < b || c > d);"; + errout.str(""); + Settings settings; + Tokenizer tokenizer(&settings, this); + std::istringstream istr(code); + tokenizer.tokenize(istr, "test.cpp"); + const Token *tok = tokenizer.tokens(); + + ASSERT_EQUALS(true, tok->linkAt(3) == nullptr); + } } void simplifyString() {