diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index ebe5e2e12..d53add28e 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5365,11 +5365,16 @@ void Tokenizer::simplifyComma() continue; } + if (tok->str() == "(") + { + tok = tok->link(); + continue; + } + // Skip unhandled template specifiers.. if (Token::Match(tok, "%var% <")) { // Todo.. use the link instead. - unsigned int parlevel = 0; unsigned int comparelevel = 0; for (Token *tok2 = tok; tok2; tok2 = tok2->next()) { @@ -5384,14 +5389,6 @@ void Tokenizer::simplifyComma() } ++comparelevel; } - else if (tok2->str() == "(") - ++parlevel; - else if (tok2->str() == ")") - { - if (parlevel == 0) - break; - --parlevel; - } else if (Token::Match(tok2, "[;{}]")) break; } diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 024c10126..1a1bede83 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -1878,6 +1878,19 @@ private: "}\n"; ASSERT_EQUALS("void f ( ) { int a ; a = b < T < char , 3 > , int > ( ) ; }", sizeof_(code)); } + + { + // ticket #1327 + const char code[] = "const C<1,2,3> foo ()\n" + "{\n" + " return C<1,2,3>(x,y);\n" + "}\n"; + const char expected[] = "const C < 1 , 2 , 3 > foo ( ) " + "{" + " return C < 1 , 2 , 3 > ( x , y ) ; " + "}"; + ASSERT_EQUALS(expected, sizeof_(code)); + } } void conditionOperator()