From ad33d95ec1e5fb3cb0c6490c5fab69d450efc56a Mon Sep 17 00:00:00 2001 From: Simon Martin Date: Fri, 9 Aug 2013 23:40:00 +0200 Subject: [PATCH] Ticket #4764: properly handle template instantiations with only default parameters. --- lib/tokenize.cpp | 4 +++- test/testbufferoverrun.cpp | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 44f459b3e..365ef8261 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"