diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 40dbdf88f9d..841acb914df 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -8995,7 +8995,7 @@ void Tokenizer::findGarbageCode() const syntaxError(tok); if (Token::Match(tok, "[;([{] %comp%|%oror%|%or%|%|/")) syntaxError(tok); - if (Token::Match(tok, "%cop%|= ]") && !Token::simpleMatch(tok, "*") && !(cpp && Token::Match(tok->previous(), "%type%|[|,|%num% &|=|> ]"))) + if (Token::Match(tok, "%cop%|= ]") && !Token::simpleMatch(tok, "*") && !(cpp && Token::Match(tok->previous(), "%type%|[|,|<|%num% &|=|> ]"))) syntaxError(tok); if (Token::Match(tok, "[+-] [;,)]}]") && !(cpp && Token::simpleMatch(tok->previous(), "operator"))) syntaxError(tok); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index d51f224d7f8..851a63a646a 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -7821,6 +7821,8 @@ class TestTokenizer : public TestFixture { " for (int i : [](int a, int b) { ++a; ++b; return std::vector{a, b}; }(1, 2)) {}\n" "}\n")); + ASSERT_NO_THROW(tokenizeAndStringify("int y = a[x<>];")); // #14676 + ignore_errout(); }