diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index b4badf102..48955d39c 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3468,7 +3468,8 @@ void Tokenizer::setVarId() tok2 = tok2->next(); again = true; } - else if (level > 1 && Token::Match(tok2, "%type% *|&| >")) + else if (level > 1 && (Token::Match(tok2, "%type% *|&| >") || + Token::Match(tok2, "%num% >"))) { --level; while (tok2->str() != ">") diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index e0ded16e9..19bf4fb03 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -171,6 +171,7 @@ private: TEST_CASE(varid26); // ticket #1967 (list of function pointers) TEST_CASE(varid27); // Ticket #2280 (same name for namespace and variable) TEST_CASE(varid28); // ticket #2630 + TEST_CASE(varid29); // ticket #1974 TEST_CASE(varidFunctionCall1); TEST_CASE(varidFunctionCall2); TEST_CASE(varidFunctionCall3); @@ -2830,6 +2831,18 @@ private: ASSERT_EQUALS("", errout.str()); } + void varid29() + { + const std::string code("class A {\n" + " B,1> b;\n" + "};\n"); + const std::string expected("\n\n##file 0\n" + "1: class A {\n" + "2: B < C < 1 > , 1 > b@1 ;\n" + "3: } ;\n"); + ASSERT_EQUALS(expected, tokenizeDebugListing(code)); + } + void varidFunctionCall1() { const std::string code("void f() {\n"