diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index e1fed19a6..2fe0b07a3 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -8398,10 +8398,11 @@ void Tokenizer::findGarbageCode() const if (!templateEndToken) { if (tok->str() == "<" && isCPP()) templateEndToken = tok->findClosingBracket(); - } else if (templateEndToken == tok) { - templateEndToken = nullptr; - } else if (Token::Match(tok, "> %cop%")) { - continue; + } else { + if (templateEndToken == tok) + templateEndToken = nullptr; + if (Token::Match(tok, "> %cop%")) + continue; } if (Token::Match(tok, "%cop%|=|,|[ %or%|%oror%|/|%")) syntaxError(tok); diff --git a/test/testgarbage.cpp b/test/testgarbage.cpp index ae2c64b90..21f352e85 100644 --- a/test/testgarbage.cpp +++ b/test/testgarbage.cpp @@ -1457,6 +1457,7 @@ private: ASSERT_THROW(checkCode(inp), InternalError); checkCode("template struct S : A< B || C > {};"); // No syntax error: #8390 + checkCode("static_assert(A || B, ab);"); } void garbageCode188() { // #8255