Fixed handling of pointers in templates (#4319)

This commit is contained in:
PKEuS 2012-11-04 10:49:25 +01:00
parent 66627e0608
commit 9cb9388e49
2 changed files with 13 additions and 0 deletions

View File

@ -225,6 +225,7 @@ unsigned int TemplateSimplifier::templateParameters(const Token *tok)
if (!tok)
return 0;
// ,/>
while (tok->str() == ">" || tok->str() == ">>") {
if (level == 0)
@ -236,9 +237,15 @@ unsigned int TemplateSimplifier::templateParameters(const Token *tok)
--level;
}
tok = tok->next();
// * / &
while (Token::Match(tok, "[*&]"))
tok = tok->next();
if (!tok)
return 0;
}
if (tok->str() != ",")
continue;
if (level == 0)

View File

@ -259,6 +259,7 @@ private:
TEST_CASE(varid_using); // ticket #3648
TEST_CASE(varid_catch);
TEST_CASE(varid_functionPrototypeTemplate);
TEST_CASE(varid_templatePtr); // #4319
TEST_CASE(varidclass1);
TEST_CASE(varidclass2);
@ -4057,6 +4058,11 @@ private:
"1: function < void ( ) > fptr@1 ;\n", tokenizeDebugListing("function<void(void)> fptr;"));
}
void varid_templatePtr() {
ASSERT_EQUALS("\n\n##file 0\n"
"1: std :: map < int , FooTemplate < int > * > dummy_member@1 [ 1 ] ;\n", tokenizeDebugListing("std::map<int, FooTemplate<int>*> dummy_member[1];"));
}
void varidclass1() {
const std::string actual = tokenizeDebugListing(
"class Fred\n"