Ticket #4764: properly handle template instantiations with only default parameters.

This commit is contained in:
Simon Martin 2013-08-09 23:40:00 +02:00
parent 3032dbabce
commit ad33d95ec1
2 changed files with 12 additions and 1 deletions

View File

@ -2661,7 +2661,9 @@ static bool setVarIdParseDeclaration(const Token **tok, const std::map<std::stri
} else {
++typeCount;
}
} else if (tok2->str() == "<" && TemplateSimplifier::templateParameters(tok2) > 0) {
} else if ((TemplateSimplifier::templateParameters(tok2) > 0) ||
Token::Match(tok2, "< >") /* Ticket #4764 */)
{
tok2 = tok2->findClosingBracket();
if (!Token::Match(tok2, ">|>>"))
break;

View File

@ -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"