diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 2d1102291..e315540ec 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -7756,7 +7756,7 @@ void Tokenizer::findGarbageCode() const syntaxError(tok); if (Token::Match(tok, ";|(|[ %comp%")) syntaxError(tok); - if (Token::Match(tok, "%cop%|= ]") && !(isCPP() && Token::Match(tok->previous(), "[|,|%num% &|=|> ]"))) + if (Token::Match(tok, "%cop%|= ]") && !(isCPP() && Token::Match(tok->previous(), "%type%|[|,|%num% &|=|> ]"))) syntaxError(tok); if (Token::Match(tok, "[+-] [;,)]}]") && !(isCPP() && Token::Match(tok->previous(), "operator [+-] ;"))) syntaxError(tok); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 270f5870b..1e92bc8b9 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -6754,6 +6754,12 @@ private: " for (my_struct ms : { my_struct{ .x=5, .y{42} } }) {} " "}")); + ASSERT_NO_THROW(tokenizeAndStringify("template void foo() {} " + "void h() { " + " [func=foo]{func();}(); " + "}")); + + // op op ASSERT_THROW_EQUALS(tokenizeAndStringify("void f() { dostuff (x==>y); }"), InternalError, "syntax error: == >");