diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index ae17b1a0f..cf86990f0 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -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) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 4927a2494..796eb743b 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -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 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*> dummy_member[1];")); + } + void varidclass1() { const std::string actual = tokenizeDebugListing( "class Fred\n"