diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index b798d2be7..e94c3755c 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2661,7 +2661,9 @@ static bool setVarIdParseDeclaration(const Token **tok, const std::mapstr() == "<" && TemplateSimplifier::templateParameters(tok2) > 0) { + } else if ((TemplateSimplifier::templateParameters(tok2) > 0) || + Token::Match(tok2, "< >") /* Ticket #4764 */) + { tok2 = tok2->findClosingBracket(); if (!Token::Match(tok2, ">|>>")) break; diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index 6e4626444..85b655f34 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -215,6 +215,7 @@ private: TEST_CASE(varid1); TEST_CASE(varid2); + TEST_CASE(varid3); // ticket #4764 TEST_CASE(assign1); @@ -3215,6 +3216,14 @@ private: "}"); ASSERT_EQUALS("", errout.str()); } + + void varid3() { // #4764 + check("struct foo {\n" + " void bar() { return; }\n" + " type<> member[1];\n" + "};"); + ASSERT_EQUALS("", errout.str()); + } void assign1() { check("char str[3] = {'a', 'b', 'c'};\n"