diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 15af853aaed..351d4833a3e 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -8239,7 +8239,8 @@ void Tokenizer::findGarbageCode() const prev = prev->previous(); if (Token::Match(prev, "%op%|%num%|%str%|%char%")) { if (!Token::simpleMatch(tok->tokAt(-2), "operator \"\" if") && - !Token::simpleMatch(tok->tokAt(-2), "extern \"C\"")) + !Token::simpleMatch(tok->tokAt(-2), "extern \"C\"") && + !Token::simpleMatch(prev, "> typedef")) syntaxError(tok, prev == tok->previous() ? (prev->str() + " " + tok->str()) : (prev->str() + " .. " + tok->str())); } } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index b9f66926ce2..43b8d1c6b4b 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -6920,6 +6920,9 @@ class TestTokenizer : public TestFixture { ASSERT_NO_THROW(tokenizeAndStringify("template constexpr int n = 1;\n" "template T a[n];\n")); + ASSERT_EQUALS("std :: vector < int > x ;", // #11785 + tokenizeAndStringify("std::vector typedef v; v x;\n")); + // op op ASSERT_THROW_EQUALS(tokenizeAndStringify("void f() { dostuff (x==>y); }"), InternalError, "syntax error: == >");